Editing layers completed

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 3e6ce41b08
commit 2ed10ce759
  1. BIN
      C++ProjectTemplate
  2. BIN
      assets/terrainmap.png
  3. BIN
      assets/terrainmap.xcf
  4. 22
      main.cpp

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

@ -84,11 +84,12 @@ public:
state::GameState GAME_STATE = state::EDITOR;
vi2d SELECTED_TILE={0,0};
vi2d HIGHLIGHTED_TILE={0,0};
int EDITING_LAYER=2;
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
std::vector<std::vector<TILE*>> MAP;
std::vector<std::vector<TILE*>> MAP2; //The foreground layer.
std::vector<std::vector<TILE*>> MAP; //The foreground layer.
std::vector<std::vector<TILE*>> MAP2;
std::map<Reference,Decal*> SPRITES;
std::map<Reference,Animation*> ANIMATIONS;
std::map<int,Object*> OBJ_INFO;
@ -162,6 +163,12 @@ public:
if (TabHeld()) {
GAME_STATE=state::TILE_SELECT;
}
if (GetKey(K1).bHeld) {
EDITING_LAYER=2;
}
if (GetKey(K2).bHeld) {
EDITING_LAYER=3;
}
if (UpHeld()) {
cameraPos.y-=CAMERA_MOVESPD;
}
@ -180,9 +187,18 @@ public:
HIGHLIGHTED_TILE={selectedTileX,selectedTileY};
}
if (GetMouse(0).bHeld) {
switch (EDITING_LAYER) {
case 2:{
TILE*tile=MAP[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x];
tile->tileX=SELECTED_TILE.x;
tile->tileY=SELECTED_TILE.y;
}break;
case 3:{
TILE*tile=MAP2[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x];
tile->tileX=SELECTED_TILE.x;
tile->tileY=SELECTED_TILE.y;
}break;
}
}
}break;
}
@ -231,7 +247,9 @@ public:
}
}
}
SetDrawTarget(nullptr);
DrawRectDecal((HIGHLIGHTED_TILE)*32-cameraPos,{32,32},YELLOW);
DrawStringPropDecal({2,2},"Editing Layer "+std::to_string(EDITING_LAYER));
}break;
case state::TILE_SELECT:{
//14x14 pixels per tile.

Loading…
Cancel
Save