diff --git a/src/Game.cpp b/src/Game.cpp index 5ecdaa8..49daf68 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -112,6 +113,8 @@ void Game::run() { window.close(); } } + + sf::Vector2i currentPacmanTile = map.getTileCoords(pacman.getPosition()); if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W) || sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up)) { pacman.queueDirection(MovementDir::UP); @@ -172,6 +175,10 @@ void Game::run() { pacman.update(); + if (map.hasPellet(currentPacmanTile.x, currentPacmanTile.y)) { + map.eatPellet(currentPacmanTile.x, currentPacmanTile.y); + } + window.clear(); window.draw(map); window.draw(pacman);