diff --git a/common/map/map_file_format.cpp b/common/map/map_file_format.cpp index ed9f589..ee7f58d 100644 --- a/common/map/map_file_format.cpp +++ b/common/map/map_file_format.cpp @@ -21,14 +21,10 @@ */ #include "map_file_format.hpp" -#include - void MapFileFormat::Load(Region** const ptr, int x, int y) { //TODO - std::cout << "Load" << std::endl; } void MapFileFormat::Save(Region* const ptr) { //TODO - std::cout << "Save" << std::endl; } diff --git a/common/map/map_generator.cpp b/common/map/map_generator.cpp index 4f5b40b..2668ca5 100644 --- a/common/map/map_generator.cpp +++ b/common/map/map_generator.cpp @@ -21,14 +21,10 @@ */ #include "map_generator.hpp" -#include - void MapGenerator::Create(Region** const ptr, int width, int height, int depth, int x, int y) { (*ptr) = new Region(width, height, depth, x, y); - std::cout << "Create" << std::endl; } void MapGenerator::Unload(Region* const ptr) { delete ptr; - std::cout << "Unload" << std::endl; } diff --git a/common/map/region.cpp b/common/map/region.cpp index e1d614d..9f4f68e 100644 --- a/common/map/region.cpp +++ b/common/map/region.cpp @@ -21,8 +21,6 @@ */ #include "region.hpp" -#include - Region::Region(int argWidth, int argHeight, int argDepth, int argX, int argY): width(argWidth), height(argHeight), diff --git a/common/map/region_pager.cpp b/common/map/region_pager.cpp index 32d925a..a251ee8 100644 --- a/common/map/region_pager.cpp +++ b/common/map/region_pager.cpp @@ -23,8 +23,6 @@ #include "utility.hpp" -#include - RegionPagerBase::RegionPagerBase(int argWidth, int argHeight, int argDepth): regionWidth(argWidth), regionHeight(argHeight), @@ -34,18 +32,17 @@ RegionPagerBase::RegionPagerBase(int argWidth, int argHeight, int argDepth): } RegionPagerBase::~RegionPagerBase() { - std::cout << "final size: " << regionList.size() << std::endl; //EMPTY } int RegionPagerBase::SetTile(int x, int y, int z, int v) { 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) { 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) { diff --git a/common/utility.cpp b/common/utility.cpp index 4ba5fc1..38c79ef 100644 --- a/common/utility.cpp +++ b/common/utility.cpp @@ -27,9 +27,9 @@ int snapToBase(int base, int x) { //snap to a grid if (x < 0) { 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) { diff --git a/editor/editor_scene.cpp b/editor/editor_scene.cpp index 4865b2a..2709419 100644 --- a/editor/editor_scene.cpp +++ b/editor/editor_scene.cpp @@ -35,7 +35,7 @@ using namespace std; EditorScene::EditorScene(ConfigUtility* const arg1): config(*arg1), - region(20, 20, 3, 0, 0) + pager(20, 20, 3) { //create the debugging "window" debugInfo.CreateSurface(256, 256); @@ -58,9 +58,6 @@ EditorScene::EditorScene(ConfigUtility* const arg1): //debug tsheet.Load("rsc\\graphics\\tilesets\\sand.bmp", 12, 3); - cout << region.GetWidth() << endl; - cout << region.GetHeight() << endl; - cout << region.GetDepth() << endl; } EditorScene::~EditorScene() { @@ -85,14 +82,14 @@ void EditorScene::FrameEnd() { void EditorScene::Render(SDL_Surface* const screen) { //debug - for (int i = 0; i < region.GetWidth(); i++) { - for (int j = 0; j < region.GetHeight(); j++) { - for (int k = 0; k < region.GetDepth(); k++) { + for (int i = 0; i < pager.GetRegionWidth()*2; i++) { + for (int j = 0; j < pager.GetRegionHeight()*2; j++) { + for (int k = 0; k < pager.GetRegionDepth(); k++) { tsheet.DrawTo( screen, - i*tsheet.GetTileW()+region.GetX()-camera.x, - j*tsheet.GetTileH()+region.GetY()-camera.y, - region.GetTile(i,j,k) + i*tsheet.GetTileW()-camera.x, + j*tsheet.GetTileH()-camera.y, + pager.GetTile(i,j,k) ); } } diff --git a/editor/editor_scene.hpp b/editor/editor_scene.hpp index 15f4b05..d8052bd 100644 --- a/editor/editor_scene.hpp +++ b/editor/editor_scene.hpp @@ -30,6 +30,8 @@ #include "menu_bar.hpp" #include "region_pager.hpp" +#include "map_generator.hpp" +#include "map_file_format.hpp" #include "tile_sheet.hpp" class EditorScene : public BaseScene { @@ -68,7 +70,7 @@ protected: int x = 0, y = 0; } camera; - Region region; + RegionPager pager; TileSheet tsheet; };