mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 10:13:42 +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]) {
|
||||
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]) {
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user