Add impassable Wall cell

master
NaiJi ✨ 4 years ago
parent bfbb81568a
commit 8823543d4e

@ -127,6 +127,13 @@ void Game::onMoving(sf::Keyboard::Key &key)
// Hero exists the level!
loadLevel(++current_level);
break;
case CellType::Wall:
// You can't pass through wall. Hero goes back to inital coordinates
hero->setPosition(initial_x, initial_y);
break;
}
@ -175,6 +182,9 @@ void Game::renderMap()
case CellType::Exit:
rectangle_brush.setFillColor(sf::Color::Red);
break;
case CellType::Wall:
rectangle_brush.setFillColor(sf::Color(60, 60, 60)); // Gray
break;
case CellType::Water:
default:
rectangle_brush.setFillColor(sf::Color::Blue);
@ -219,6 +229,9 @@ void Game::loadLevel(int level_index)
// Hardcoding is temporary!
hero->setPosition(1, 1);
hero->setCharges(2);
map[0][0] = CellType::Wall;
map[0][1] = CellType::Wall;
map[1][0] = CellType::Wall;
map[1][1] = CellType::Ground;
map[1][2] = CellType::Ground;
map[1][3] = CellType::Ground;
@ -256,6 +269,9 @@ void Game::loadLevel(int level_index)
map[8][8] = CellType::Ground;
map[8][9] = CellType::Ground;
map[8][10] = CellType::Exit;
map[8][11] = CellType::Wall;
map[7][11] = CellType::Wall;
map[4][3] = CellType::Wall;
map[4][7] = CellType::Charge;
level->setMap(map);
break;

@ -10,7 +10,8 @@ enum class CellType
Charge = '$',
Bridge = char(177),
Hero = '@',
Exit = '#'
Exit = '#',
Wall = 'X'
};
using coordinate = unsigned int;

Loading…
Cancel
Save