Tested RegionPager, removed trace statements, fixed logic errors
This commit is contained in:
@@ -21,14 +21,10 @@
|
|||||||
*/
|
*/
|
||||||
#include "map_file_format.hpp"
|
#include "map_file_format.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
void MapFileFormat::Load(Region** const ptr, int x, int y) {
|
void MapFileFormat::Load(Region** const ptr, int x, int y) {
|
||||||
//TODO
|
//TODO
|
||||||
std::cout << "Load" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapFileFormat::Save(Region* const ptr) {
|
void MapFileFormat::Save(Region* const ptr) {
|
||||||
//TODO
|
//TODO
|
||||||
std::cout << "Save" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,14 +21,10 @@
|
|||||||
*/
|
*/
|
||||||
#include "map_generator.hpp"
|
#include "map_generator.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
void MapGenerator::Create(Region** const ptr, int width, int height, int depth, int x, int y) {
|
void MapGenerator::Create(Region** const ptr, int width, int height, int depth, int x, int y) {
|
||||||
(*ptr) = new Region(width, height, depth, x, y);
|
(*ptr) = new Region(width, height, depth, x, y);
|
||||||
std::cout << "Create" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapGenerator::Unload(Region* const ptr) {
|
void MapGenerator::Unload(Region* const ptr) {
|
||||||
delete ptr;
|
delete ptr;
|
||||||
std::cout << "Unload" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "region.hpp"
|
#include "region.hpp"
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
Region::Region(int argWidth, int argHeight, int argDepth, int argX, int argY):
|
Region::Region(int argWidth, int argHeight, int argDepth, int argX, int argY):
|
||||||
width(argWidth),
|
width(argWidth),
|
||||||
height(argHeight),
|
height(argHeight),
|
||||||
|
|||||||
@@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
RegionPagerBase::RegionPagerBase(int argWidth, int argHeight, int argDepth):
|
RegionPagerBase::RegionPagerBase(int argWidth, int argHeight, int argDepth):
|
||||||
regionWidth(argWidth),
|
regionWidth(argWidth),
|
||||||
regionHeight(argHeight),
|
regionHeight(argHeight),
|
||||||
@@ -34,18 +32,17 @@ RegionPagerBase::RegionPagerBase(int argWidth, int argHeight, int argDepth):
|
|||||||
}
|
}
|
||||||
|
|
||||||
RegionPagerBase::~RegionPagerBase() {
|
RegionPagerBase::~RegionPagerBase() {
|
||||||
std::cout << "final size: " << regionList.size() << std::endl;
|
|
||||||
//EMPTY
|
//EMPTY
|
||||||
}
|
}
|
||||||
|
|
||||||
int RegionPagerBase::SetTile(int x, int y, int z, int v) {
|
int RegionPagerBase::SetTile(int x, int y, int z, int v) {
|
||||||
Region* ptr = GetRegion(x, y);
|
Region* ptr = GetRegion(x, y);
|
||||||
return ptr->SetTile(x - ptr->GetX(), y = ptr->GetY(), z, v);
|
return ptr->SetTile(x - ptr->GetX(), y - ptr->GetY(), z, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
int RegionPagerBase::GetTile(int x, int y, int z) {
|
int RegionPagerBase::GetTile(int x, int y, int z) {
|
||||||
Region* ptr = GetRegion(x, y);
|
Region* ptr = GetRegion(x, y);
|
||||||
return ptr->GetTile(x - ptr->GetX(), y = ptr->GetY(), z);
|
return ptr->GetTile(x - ptr->GetX(), y - ptr->GetY(), z);
|
||||||
}
|
}
|
||||||
|
|
||||||
Region* RegionPagerBase::GetRegion(int x, int y) {
|
Region* RegionPagerBase::GetRegion(int x, int y) {
|
||||||
|
|||||||
+2
-2
@@ -27,9 +27,9 @@ int snapToBase(int base, int x) {
|
|||||||
//snap to a grid
|
//snap to a grid
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
x++;
|
x++;
|
||||||
return x - x % base - base;
|
return x / base * base - base;
|
||||||
}
|
}
|
||||||
return x - x % base;
|
return x / base * base;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string truncatePath(std::string pathname) {
|
std::string truncatePath(std::string pathname) {
|
||||||
|
|||||||
+7
-10
@@ -35,7 +35,7 @@ using namespace std;
|
|||||||
|
|
||||||
EditorScene::EditorScene(ConfigUtility* const arg1):
|
EditorScene::EditorScene(ConfigUtility* const arg1):
|
||||||
config(*arg1),
|
config(*arg1),
|
||||||
region(20, 20, 3, 0, 0)
|
pager(20, 20, 3)
|
||||||
{
|
{
|
||||||
//create the debugging "window"
|
//create the debugging "window"
|
||||||
debugInfo.CreateSurface(256, 256);
|
debugInfo.CreateSurface(256, 256);
|
||||||
@@ -58,9 +58,6 @@ EditorScene::EditorScene(ConfigUtility* const arg1):
|
|||||||
|
|
||||||
//debug
|
//debug
|
||||||
tsheet.Load("rsc\\graphics\\tilesets\\sand.bmp", 12, 3);
|
tsheet.Load("rsc\\graphics\\tilesets\\sand.bmp", 12, 3);
|
||||||
cout << region.GetWidth() << endl;
|
|
||||||
cout << region.GetHeight() << endl;
|
|
||||||
cout << region.GetDepth() << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorScene::~EditorScene() {
|
EditorScene::~EditorScene() {
|
||||||
@@ -85,14 +82,14 @@ void EditorScene::FrameEnd() {
|
|||||||
|
|
||||||
void EditorScene::Render(SDL_Surface* const screen) {
|
void EditorScene::Render(SDL_Surface* const screen) {
|
||||||
//debug
|
//debug
|
||||||
for (int i = 0; i < region.GetWidth(); i++) {
|
for (int i = 0; i < pager.GetRegionWidth()*2; i++) {
|
||||||
for (int j = 0; j < region.GetHeight(); j++) {
|
for (int j = 0; j < pager.GetRegionHeight()*2; j++) {
|
||||||
for (int k = 0; k < region.GetDepth(); k++) {
|
for (int k = 0; k < pager.GetRegionDepth(); k++) {
|
||||||
tsheet.DrawTo(
|
tsheet.DrawTo(
|
||||||
screen,
|
screen,
|
||||||
i*tsheet.GetTileW()+region.GetX()-camera.x,
|
i*tsheet.GetTileW()-camera.x,
|
||||||
j*tsheet.GetTileH()+region.GetY()-camera.y,
|
j*tsheet.GetTileH()-camera.y,
|
||||||
region.GetTile(i,j,k)
|
pager.GetTile(i,j,k)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
#include "menu_bar.hpp"
|
#include "menu_bar.hpp"
|
||||||
|
|
||||||
#include "region_pager.hpp"
|
#include "region_pager.hpp"
|
||||||
|
#include "map_generator.hpp"
|
||||||
|
#include "map_file_format.hpp"
|
||||||
#include "tile_sheet.hpp"
|
#include "tile_sheet.hpp"
|
||||||
|
|
||||||
class EditorScene : public BaseScene {
|
class EditorScene : public BaseScene {
|
||||||
@@ -68,7 +70,7 @@ protected:
|
|||||||
int x = 0, y = 0;
|
int x = 0, y = 0;
|
||||||
} camera;
|
} camera;
|
||||||
|
|
||||||
Region region;
|
RegionPager<MapGenerator, MapFileFormat> pager;
|
||||||
TileSheet tsheet;
|
TileSheet tsheet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user