diff options
Diffstat (limited to 'game/player/PlayerScript.cpp')
-rw-r--r-- | game/player/PlayerScript.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/game/player/PlayerScript.cpp b/game/player/PlayerScript.cpp index 96a0552..4e253f4 100644 --- a/game/player/PlayerScript.cpp +++ b/game/player/PlayerScript.cpp @@ -4,6 +4,7 @@ #include "../Config.h" #include "../enemy/BattleScript.h" #include <crepe/api/Animator.h> +#include <crepe/api/AudioSource.h> #include <crepe/api/ParticleEmitter.h> #include <crepe/api/Rigidbody.h> #include <crepe/api/BoxCollider.h> @@ -38,7 +39,11 @@ bool PlayerScript::on_collision(const CollisionEvent & ev) { } play_scr.active = false; end_scr.active = true; - return true; + + AudioSource & audio = this->get_components_by_name<AudioSource>("player").at(0); + audio.play(); + + return false; } else if (ev.info.other.metadata.tag == "laser") { for (Animator & anim : animators) { anim.active = true; @@ -51,7 +56,11 @@ bool PlayerScript::on_collision(const CollisionEvent & ev) { } play_scr.active = false; end_scr.active = true; - return true; + + AudioSource & audio = this->get_components_by_name<AudioSource>("player").at(1); + audio.play(); + + return false; } else if (ev.info.other.metadata.tag == "missile") { for (Animator & anim : animators) { anim.active = true; @@ -64,7 +73,11 @@ bool PlayerScript::on_collision(const CollisionEvent & ev) { } play_scr.active = false; end_scr.active = true; - return true; + + AudioSource & audio = this->get_components_by_name<AudioSource>("player").at(2); + audio.play(); + + return false; } return false; @@ -108,6 +121,15 @@ void PlayerScript::fixed_update(crepe::duration_t dt) { emitter.data.emission_rate = 30; } } + + AudioSource & audio = this->get_components_by_name<AudioSource>("player").at( + 3 + current_jetpack_sound + ); + audio.play(); + current_jetpack_sound++; + if (current_jetpack_sound > 7) { + current_jetpack_sound = 0; + } } else if (transform.position.y == 195) { if (prev_anim != 0) { for (Animator & anim : animators) { |