From d7fd4ec14a5304b87d984f5150e48ab99f4f8834 Mon Sep 17 00:00:00 2001 From: dylanbenzi Date: Mon, 10 Nov 2025 17:10:05 -0500 Subject: [PATCH] add pacman eating pellets --- src/Game.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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);