mirror of
https://github.com/dylanbenzi/pacmen-sfml.git
synced 2026-11-27 08:26:59 +00:00
add dot eating sounds
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user