add dot eating sounds

This commit is contained in:
2025-11-10 17:17:13 -05:00
parent d7fd4ec14a
commit 294781b449
+13
View File
@@ -104,6 +104,11 @@ void Game::run() {
sf::Sound sound(*resources.getSound("start")); sf::Sound sound(*resources.getSound("start"));
sound.play(); sound.play();
sf::Sound pellet0(*resources.getSound("eat_dot_0"));
sf::Sound pellet1(*resources.getSound("eat_dot_1"));
int pelletSoundCount = 0;
while (window.isOpen()) while (window.isOpen())
{ {
while (const std::optional event = window.pollEvent()) while (const std::optional event = window.pollEvent())
@@ -177,6 +182,14 @@ void Game::run() {
if (map.hasPellet(currentPacmanTile.x, currentPacmanTile.y)) { if (map.hasPellet(currentPacmanTile.x, currentPacmanTile.y)) {
map.eatPellet(currentPacmanTile.x, currentPacmanTile.y); map.eatPellet(currentPacmanTile.x, currentPacmanTile.y);
if (pelletSoundCount % 2) {
pellet0.play();
} else {
pellet1.play();
}
pelletSoundCount++;
} }
window.clear(); window.clear();