diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-07 15:01:02 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-07 15:01:02 +0100 |
commit | f8ffac3b14d41e7d1e43ffe64750d910ed333b0d (patch) | |
tree | 1417b93d5e57df858f0cd4177e3c8b5ffbcc021b /game/player/PlayerAudioScript.cpp | |
parent | 5d798c30af7026099344a068e91e1684018b4386 (diff) | |
parent | f31bd86ae5d7df21b788a273d4f2e530136ec184 (diff) |
another merge + WIP
Diffstat (limited to 'game/player/PlayerAudioScript.cpp')
-rw-r--r-- | game/player/PlayerAudioScript.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/game/player/PlayerAudioScript.cpp b/game/player/PlayerAudioScript.cpp new file mode 100644 index 0000000..6b5f630 --- /dev/null +++ b/game/player/PlayerAudioScript.cpp @@ -0,0 +1,62 @@ +#include "PlayerAudioScript.h" + +#include <crepe/api/Animator.h> +#include <crepe/api/AudioSource.h> + +using namespace crepe; +using namespace std; + +void PlayerAudioScript::fixed_update(crepe::duration_t dt) { + Animator & animator = this->get_components_by_name<Animator>("player").front(); + + if (animator.data.col == 0) { + if (animator.data.row != this->last_row) { + if (animator.data.row == 0) { + // right footstep + if (current_footstep == 0) { + AudioSource & audio + = this->get_components_by_name<AudioSource>("player_audio").at(0); + audio.play(); + } else if (current_footstep == 1) { + AudioSource & audio + = this->get_components_by_name<AudioSource>("player_audio").at(2); + audio.play(); + } else if (current_footstep == 2) { + AudioSource & audio + = this->get_components_by_name<AudioSource>("player_audio").at(4); + audio.play(); + } else if (current_footstep == 3) { + AudioSource & audio + = this->get_components_by_name<AudioSource>("player_audio").at(6); + audio.play(); + } + } else if (animator.data.row == 2) { + // left footstep + if (current_footstep == 0) { + AudioSource & audio + = this->get_components_by_name<AudioSource>("player_audio").at(1); + audio.play(); + current_footstep = 1; + } else if (current_footstep == 1) { + AudioSource & audio + = this->get_components_by_name<AudioSource>("player_audio").at(3); + audio.play(); + current_footstep = 2; + } else if (current_footstep == 2) { + AudioSource & audio + = this->get_components_by_name<AudioSource>("player_audio").at(5); + audio.play(); + current_footstep = 3; + } else if (current_footstep == 3) { + AudioSource & audio + = this->get_components_by_name<AudioSource>("player_audio").at(7); + audio.play(); + current_footstep = 0; + } + } + this->last_row = animator.data.row; + } + } else { + this->last_row = -1; + } +} |