aboutsummaryrefslogtreecommitdiff
path: root/game/player/PlayerScript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'game/player/PlayerScript.cpp')
-rw-r--r--game/player/PlayerScript.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/game/player/PlayerScript.cpp b/game/player/PlayerScript.cpp
index c151d53..d45a519 100644
--- a/game/player/PlayerScript.cpp
+++ b/game/player/PlayerScript.cpp
@@ -3,6 +3,7 @@
#include "../Config.h"
#include <crepe/api/Animator.h>
+#include <crepe/api/AudioSource.h>
#include <crepe/api/ParticleEmitter.h>
#include <crepe/api/Rigidbody.h>
#include <crepe/api/Transform.h>
@@ -36,6 +37,10 @@ bool PlayerScript::on_collision(const CollisionEvent & ev) {
}
play_scr.active = false;
end_scr.active = 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) {
@@ -49,6 +54,10 @@ bool PlayerScript::on_collision(const CollisionEvent & ev) {
}
play_scr.active = false;
end_scr.active = 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) {
@@ -62,6 +71,10 @@ bool PlayerScript::on_collision(const CollisionEvent & ev) {
}
play_scr.active = false;
end_scr.active = true;
+
+ AudioSource & audio = this->get_components_by_name<AudioSource>("player").at(2);
+ audio.play();
+
return false;
}
@@ -92,6 +105,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) {