Fixed Region's internals
This commit is contained in:
@@ -49,4 +49,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
+19
-4
@@ -30,17 +30,32 @@ Region::Region(int argWidth, int argHeight, int argDepth, int argX, int argY):
|
|||||||
x(argX),
|
x(argX),
|
||||||
y(argY)
|
y(argY)
|
||||||
{
|
{
|
||||||
tiles = static_cast<int*>(calloc(width * height * depth, sizeof(int)));
|
tiles = new int**[width];
|
||||||
|
for (int i = 0; i < width; ++i) {
|
||||||
|
tiles[i] = new int*[height];
|
||||||
|
for (int j = 0; j < height; ++j) {
|
||||||
|
tiles[i][j] = new int[depth];
|
||||||
|
for (int k = 0; k < depth; ++k) {
|
||||||
|
tiles[i][j][k] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Region::~Region() {
|
Region::~Region() {
|
||||||
free(tiles);
|
for (int i = 0; i < width; ++i) {
|
||||||
|
for (int j = 0; j < height; j++) {
|
||||||
|
delete tiles[i][j];
|
||||||
|
}
|
||||||
|
delete tiles[i];
|
||||||
|
}
|
||||||
|
delete tiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Region::SetTile(int x, int y, int z, int v) {
|
int Region::SetTile(int x, int y, int z, int v) {
|
||||||
return *(tiles + x*width + y*height + z*depth) = v;
|
return tiles[x][y][z] = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Region::GetTile(int x, int y, int z) {
|
int Region::GetTile(int x, int y, int z) {
|
||||||
return *(tiles + x*width + y*height + z*depth);
|
return tiles[x][y][z];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ private:
|
|||||||
const int x;
|
const int x;
|
||||||
const int y;
|
const int y;
|
||||||
|
|
||||||
int* tiles = nullptr;
|
int*** tiles = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+12
-8
@@ -35,7 +35,7 @@ using namespace std;
|
|||||||
|
|
||||||
EditorScene::EditorScene(ConfigUtility* const arg1):
|
EditorScene::EditorScene(ConfigUtility* const arg1):
|
||||||
config(*arg1),
|
config(*arg1),
|
||||||
region(20, 20, 1, 0, 0)
|
region(20, 20, 3, 0, 0)
|
||||||
{
|
{
|
||||||
//create the debugging "window"
|
//create the debugging "window"
|
||||||
debugInfo.CreateSurface(256, 256);
|
debugInfo.CreateSurface(256, 256);
|
||||||
@@ -51,8 +51,8 @@ EditorScene::EditorScene(ConfigUtility* const arg1):
|
|||||||
menuBar.SetImage(&buttonImage);
|
menuBar.SetImage(&buttonImage);
|
||||||
|
|
||||||
menuBar.SetEntries({
|
menuBar.SetEntries({
|
||||||
{"File", "-New", "-Open", "-Save", "-Save As...", "-Close", "Exit"},
|
{"File", "New", "Open", "Save", "Save As...", "Close", "Exit"},
|
||||||
{"Edit", "-Set Tile", "-Load Sheet", "-Delete Sheet", "-Metadata", "-Run Script"},
|
{"Edit", "Set Tile", "Load Sheet", "Delete Sheet", "Metadata", "Run Script"},
|
||||||
{"Debugging", "Debug On", "Debug Off", "Toggle Debug", "Testificate"}
|
{"Debugging", "Debug On", "Debug Off", "Toggle Debug", "Testificate"}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -87,10 +87,14 @@ void EditorScene::Render(SDL_Surface* const screen) {
|
|||||||
//debug
|
//debug
|
||||||
for (int i = 0; i < region.GetWidth(); i++) {
|
for (int i = 0; i < region.GetWidth(); i++) {
|
||||||
for (int j = 0; j < region.GetHeight(); j++) {
|
for (int j = 0; j < region.GetHeight(); j++) {
|
||||||
// for (int k = 0; k < region.GetDepth(); k++) {
|
for (int k = 0; k < region.GetDepth(); k++) {
|
||||||
cout << region.GetTile(i,j,0) << endl;
|
tsheet.DrawTo(
|
||||||
tsheet.DrawTo(screen, i*tsheet.GetTileW(), j*tsheet.GetTileH(), region.GetTile(i,j,0));
|
screen,
|
||||||
// }
|
i*tsheet.GetTileW()+region.GetX()-camera.x,
|
||||||
|
j*tsheet.GetTileH()+region.GetY()-camera.y,
|
||||||
|
region.GetTile(i,j,k)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +172,7 @@ void EditorScene::MouseButtonUp(SDL_MouseButtonEvent const& button) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: {
|
case 5: {
|
||||||
//Quit
|
//EXIT
|
||||||
SDL_Event e;
|
SDL_Event e;
|
||||||
e.type = SDL_QUIT;
|
e.type = SDL_QUIT;
|
||||||
SDL_PushEvent(&e);
|
SDL_PushEvent(&e);
|
||||||
|
|||||||
Reference in New Issue
Block a user