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! // Hero exists the level!
loadLevel(++current_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; break;
} }
@ -175,6 +182,9 @@ void Game::renderMap()
case CellType::Exit: case CellType::Exit:
rectangle_brush.setFillColor(sf::Color::Red); rectangle_brush.setFillColor(sf::Color::Red);
break; break;
case CellType::Wall:
rectangle_brush.setFillColor(sf::Color(60, 60, 60)); // Gray
break;
case CellType::Water: case CellType::Water:
default: default:
rectangle_brush.setFillColor(sf::Color::Blue); rectangle_brush.setFillColor(sf::Color::Blue);
@ -219,6 +229,9 @@ void Game::loadLevel(int level_index)
// Hardcoding is temporary! // Hardcoding is temporary!
hero->setPosition(1, 1); hero->setPosition(1, 1);
hero->setCharges(2); 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][1] = CellType::Ground;
map[1][2] = CellType::Ground; map[1][2] = CellType::Ground;
map[1][3] = CellType::Ground; map[1][3] = CellType::Ground;
@ -256,6 +269,9 @@ void Game::loadLevel(int level_index)
map[8][8] = CellType::Ground; map[8][8] = CellType::Ground;
map[8][9] = CellType::Ground; map[8][9] = CellType::Ground;
map[8][10] = CellType::Exit; 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; map[4][7] = CellType::Charge;
level->setMap(map); level->setMap(map);
break; break;

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

Loading…
Cancel
Save