diff --git a/assets/sound/steps.wav b/assets/sound/steps.wav new file mode 100644 index 0000000..a060c29 Binary files /dev/null and b/assets/sound/steps.wav differ diff --git a/assets/sound/throw_egg.wav b/assets/sound/throw_egg.wav new file mode 100644 index 0000000..67dc0e7 Binary files /dev/null and b/assets/sound/throw_egg.wav differ diff --git a/src/KeyboardController.cpp b/src/KeyboardController.cpp index ebe7bb2..32e9f35 100644 --- a/src/KeyboardController.cpp +++ b/src/KeyboardController.cpp @@ -30,20 +30,24 @@ void KeyboardController::update() if (keystates[this->up]) { transform->velocity.y = -1; sprite->playAnimation(WALK); + SoundManager::playSound(STEPS); } if (keystates[this->left]) { transform->velocity.x = -1; sprite->playAnimation(WALK); sprite->setDirection(LEFT); + SoundManager::playSound(STEPS); } if (keystates[this->down]) { transform->velocity.y = 1; sprite->playAnimation(WALK); + SoundManager::playSound(STEPS); } if (keystates[this->right]) { transform->velocity.x = 1; sprite->playAnimation(WALK); sprite->setDirection(RIGHT); + SoundManager::playSound(STEPS); } if (keystates[this->fire]) { diff --git a/src/SoundManager.cpp b/src/SoundManager.cpp index e708b2b..590aa46 100644 --- a/src/SoundManager.cpp +++ b/src/SoundManager.cpp @@ -32,9 +32,13 @@ void SoundManager::playSound(SoundTypes sound) switch (sound) { case SoundTypes::STEPS: + if (Mix_Playing(-1) != 0) + break; + if (Mix_PlayChannel(-1, Game::assets->getSound("steps"), 0) == -1) { std::cerr << "Error playing sound 'steps': " << Mix_GetError() << std::endl; } + break; case SoundTypes::THROW_EGG: