mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 13:43:41 +00:00
walking sounds implemented
This commit is contained in:
parent
06a603b9d5
commit
3bd9f8d9e2
BIN
assets/sound/steps.wav
Normal file
BIN
assets/sound/steps.wav
Normal file
Binary file not shown.
BIN
assets/sound/throw_egg.wav
Normal file
BIN
assets/sound/throw_egg.wav
Normal file
Binary file not shown.
@ -30,20 +30,24 @@ void KeyboardController::update()
|
|||||||
if (keystates[this->up]) {
|
if (keystates[this->up]) {
|
||||||
transform->velocity.y = -1;
|
transform->velocity.y = -1;
|
||||||
sprite->playAnimation(WALK);
|
sprite->playAnimation(WALK);
|
||||||
|
SoundManager::playSound(STEPS);
|
||||||
}
|
}
|
||||||
if (keystates[this->left]) {
|
if (keystates[this->left]) {
|
||||||
transform->velocity.x = -1;
|
transform->velocity.x = -1;
|
||||||
sprite->playAnimation(WALK);
|
sprite->playAnimation(WALK);
|
||||||
sprite->setDirection(LEFT);
|
sprite->setDirection(LEFT);
|
||||||
|
SoundManager::playSound(STEPS);
|
||||||
}
|
}
|
||||||
if (keystates[this->down]) {
|
if (keystates[this->down]) {
|
||||||
transform->velocity.y = 1;
|
transform->velocity.y = 1;
|
||||||
sprite->playAnimation(WALK);
|
sprite->playAnimation(WALK);
|
||||||
|
SoundManager::playSound(STEPS);
|
||||||
}
|
}
|
||||||
if (keystates[this->right]) {
|
if (keystates[this->right]) {
|
||||||
transform->velocity.x = 1;
|
transform->velocity.x = 1;
|
||||||
sprite->playAnimation(WALK);
|
sprite->playAnimation(WALK);
|
||||||
sprite->setDirection(RIGHT);
|
sprite->setDirection(RIGHT);
|
||||||
|
SoundManager::playSound(STEPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keystates[this->fire]) {
|
if (keystates[this->fire]) {
|
||||||
|
|||||||
@ -32,9 +32,13 @@ void SoundManager::playSound(SoundTypes sound)
|
|||||||
switch (sound)
|
switch (sound)
|
||||||
{
|
{
|
||||||
case SoundTypes::STEPS:
|
case SoundTypes::STEPS:
|
||||||
|
if (Mix_Playing(-1) != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
if (Mix_PlayChannel(-1, Game::assets->getSound("steps"), 0) == -1) {
|
if (Mix_PlayChannel(-1, Game::assets->getSound("steps"), 0) == -1) {
|
||||||
std::cerr << "Error playing sound 'steps': " << Mix_GetError() << std::endl;
|
std::cerr << "Error playing sound 'steps': " << Mix_GetError() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SoundTypes::THROW_EGG:
|
case SoundTypes::THROW_EGG:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user