Remove/Add Walls to editor.

linux_template
sigonasr2 2 years ago
parent d59aa56318
commit 8e8b2586bb
  1. 44
      Faceball2030/Editor.cpp
  2. 9
      Faceball2030/Editor.h
  3. 1
      Faceball2030/pixelGameEngine.h

@ -10,12 +10,45 @@ void Editor::Update(float fElapsedTime){
vf2d center = { -(float)MAP_SIZE.x / 2 * GRID_SIZE.x + game->ScreenWidth()/2 , -(float)MAP_SIZE.y / 2 * GRID_SIZE.y + game->ScreenHeight()/2 }; vf2d center = { -(float)MAP_SIZE.x / 2 * GRID_SIZE.x + game->ScreenWidth()/2 , -(float)MAP_SIZE.y / 2 * GRID_SIZE.y + game->ScreenHeight()/2 };
for (int y = 0; y < MAP_SIZE.y; y++) { for (int y = 0; y < MAP_SIZE.y; y++) {
for (int x = 0; x < MAP_SIZE.x; x++) { for (int x = 0; x < MAP_SIZE.x; x++) {
Tile&t = map[y][x];
vf2d squarePos = vf2d{ (float)x,(float)y }*GRID_SIZE + center; vf2d squarePos = vf2d{ (float)x,(float)y }*GRID_SIZE + center;
if (game->GetMouseX() >= squarePos.x && game->GetMouseX() <= squarePos.x + GRID_SIZE.x && if (game->GetMouseX() >= squarePos.x && game->GetMouseX() <= squarePos.x + GRID_SIZE.x &&
game->GetMouseY() >= squarePos.y && game->GetMouseY() <= squarePos.y + GRID_SIZE.y) { game->GetMouseY() >= squarePos.y && game->GetMouseY() <= squarePos.y + GRID_SIZE.y) {
if (game->GetKey(W).bPressed) {
t.wallN = !t.wallN;
if (y > 0) {
Tile& neighbor = map[y - 1][x];
neighbor.wallS = t.wallN;
}
}
if (game->GetKey(D).bPressed) {
t.wallE = !t.wallE;
if (x < MAP_SIZE.x-1) {
Tile& neighbor = map[y][x+1];
neighbor.wallW = t.wallE;
}
}
if (game->GetKey(S).bPressed) {
t.wallS = !t.wallS;
if (y < MAP_SIZE.y - 1) {
Tile& neighbor = map[y+1][x];
neighbor.wallN = t.wallS;
}
}
if (game->GetKey(A).bPressed) {
t.wallW = !t.wallW;
if (x > 0) {
Tile& neighbor = map[y][x-1];
neighbor.wallE = t.wallW;
}
}
game->FillRectDecal(squarePos, GRID_SIZE, { 0,0,255,64 }); game->FillRectDecal(squarePos, GRID_SIZE, { 0,0,255,64 });
} }
game->DrawRectDecal(squarePos,GRID_SIZE); //game->DrawRectDecal(squarePos,GRID_SIZE,{64,64,64});
game->DrawLineDecal(squarePos,{squarePos.x+GRID_SIZE.x,squarePos.y},t.wallN?WHITE:Pixel{64,64,64});
game->DrawLineDecal({ squarePos.x + GRID_SIZE.x,squarePos.y }, { squarePos.x + GRID_SIZE.x,squarePos.y + GRID_SIZE.y }, t.wallE ? WHITE : Pixel{ 64,64,64 });
game->DrawLineDecal({ squarePos.x + GRID_SIZE.x,squarePos.y + GRID_SIZE.y }, { squarePos.x,squarePos.y + GRID_SIZE.y }, t.wallS ? WHITE : Pixel{ 64,64,64 });
game->DrawLineDecal({ squarePos.x,squarePos.y + GRID_SIZE.y }, squarePos, t.wallW ? WHITE : Pixel{ 64,64,64 });
} }
} }
} }
@ -66,8 +99,13 @@ void Editor::LoadLevel() {
newTile.blink = (map_data & 0b1000000000000000) >> 15; newTile.blink = (map_data & 0b1000000000000000) >> 15;
newTile.facingDir = FacingDirection((map_data & 0b0110000000000000) >> 13); newTile.facingDir = FacingDirection((map_data & 0b0110000000000000) >> 13);
newTile.enemyId = EnemyID((map_data & 0b0001111110000000) >> 7); newTile.enemyId = EnemyID((map_data & 0b0001111110000000) >> 7);
newTile.spawnWave = (map_data & 0b1110000) >> 4; newTile.wave1 = (map_data & 0b10000) >> 4;
newTile.walls = map_data & 0b1111; newTile.wave2 = (map_data & 0b100000) >> 5;
newTile.wave3 = (map_data & 0b1000000) >> 6;
newTile.wallN = (map_data & 0b1000) >> 3;
newTile.wallE = (map_data & 0b100) >> 2;
newTile.wallS = (map_data & 0b10) >> 1;
newTile.wallW = (map_data & 0b1);
row.push_back(newTile); row.push_back(newTile);
} }
map.push_back(row); map.push_back(row);

@ -37,8 +37,13 @@ enum WallDirection {
struct Tile { struct Tile {
EnemyID enemyId=SHOOTME; EnemyID enemyId=SHOOTME;
FacingDirection facingDir=FacingDirection::EAST; FacingDirection facingDir=FacingDirection::EAST;
byte spawnWave=0; bool wave1 = false;
byte walls=0; bool wave2 = false;
bool wave3 = false;
bool wallN = false;
bool wallE = false;
bool wallS = false;
bool wallW = false;
bool blink=false; bool blink=false;
}; };

@ -2840,6 +2840,7 @@ namespace olc
di.pos.resize(di.points); di.pos.resize(di.points);
di.uv.resize(di.points); di.uv.resize(di.points);
di.w.resize(di.points); di.w.resize(di.points);
di.z.resize(di.points);
di.tint.resize(di.points); di.tint.resize(di.points);
di.pos[0] = { (pos1.x * vInvScreenSize.x) * 2.0f - 1.0f, ((pos1.y * vInvScreenSize.y) * 2.0f - 1.0f) * -1.0f }; di.pos[0] = { (pos1.x * vInvScreenSize.x) * 2.0f - 1.0f, ((pos1.y * vInvScreenSize.y) * 2.0f - 1.0f) * -1.0f };
di.uv[0] = { 0.0f, 0.0f }; di.uv[0] = { 0.0f, 0.0f };

Loading…
Cancel
Save