aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
authorMax-001 <maxsmits21@kpnmail.nl>2025-01-06 16:46:55 +0100
committerMax-001 <maxsmits21@kpnmail.nl>2025-01-06 16:46:55 +0100
commitc8b1eb57bb373f80be9055baa51fed24e531373e (patch)
treed7a8e4367872c1686aed4db1d2c096ae984c35f8 /game
parent2f278d36afd79efafaa5ed08ef123789b5563680 (diff)
Added more audio
Diffstat (limited to 'game')
-rw-r--r--game/player/PlayerScript.cpp22
-rw-r--r--game/player/PlayerScript.h1
-rw-r--r--game/player/PlayerSubScene.cpp13
3 files changed, 36 insertions, 0 deletions
diff --git a/game/player/PlayerScript.cpp b/game/player/PlayerScript.cpp
index 472d7c8..4404bd8 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 true;
} 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 true;
} 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 true;
}
@@ -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) {
diff --git a/game/player/PlayerScript.h b/game/player/PlayerScript.h
index d8eb098..482b40d 100644
--- a/game/player/PlayerScript.h
+++ b/game/player/PlayerScript.h
@@ -13,4 +13,5 @@ private:
private:
int prev_anim = 0;
+ int current_jetpack_sound = 0;
};
diff --git a/game/player/PlayerSubScene.cpp b/game/player/PlayerSubScene.cpp
index 11575c6..41fcf51 100644
--- a/game/player/PlayerSubScene.cpp
+++ b/game/player/PlayerSubScene.cpp
@@ -4,6 +4,7 @@
#include "PlayerScript.h"
#include "../Config.h"
+#include "api/Asset.h"
#include <crepe/api/Animator.h>
#include <crepe/api/AudioSource.h>
@@ -153,6 +154,18 @@ PlayerSubScene::PlayerSubScene(Scene & scn) {
player.add_component<BehaviorScript>().set_script<PlayerScript>().active = false;
player.add_component<BehaviorScript>().set_script<PlayerEndScript>().active = false;
+ player.add_component<AudioSource>(Asset("asset/sfx/dud_zapper_lp.ogg"));
+ player.add_component<AudioSource>(Asset("asset/sfx/dud_zapper_pop.ogg"));
+ player.add_component<AudioSource>(Asset("asset/sfx/dud_fire.ogg"));
+ player.add_component<AudioSource>(Asset("asset/sfx/jetpack_firecracker_lp_01.ogg"));
+ player.add_component<AudioSource>(Asset("asset/sfx/jetpack_firecracker_lp_02.ogg"));
+ player.add_component<AudioSource>(Asset("asset/sfx/jetpack_firecracker_lp_03.ogg"));
+ player.add_component<AudioSource>(Asset("asset/sfx/jetpack_firecracker_lp_04.ogg"));
+ player.add_component<AudioSource>(Asset("asset/sfx/jetpack_firecracker_lp_05.ogg"));
+ player.add_component<AudioSource>(Asset("asset/sfx/jetpack_firecracker_lp_06.ogg"));
+ player.add_component<AudioSource>(Asset("asset/sfx/jetpack_firecracker_lp_07.ogg"));
+ player.add_component<AudioSource>(Asset("asset/sfx/jetpack_firecracker_lp_08.ogg"));
+
GameObject player_audio = scn.new_object("player_audio", "player_audio", vec2(0, 0));
player_audio.add_component<AudioSource>(Asset("asset/sfx/barefoot_step_left_1.ogg"));
player_audio.add_component<AudioSource>(Asset("asset/sfx/barefoot_step_right_1.ogg"));