diff options
-rw-r--r-- | game/coins/CoinScript.cpp | 8 | ||||
-rw-r--r-- | game/coins/CoinSubScene.cpp | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/game/coins/CoinScript.cpp b/game/coins/CoinScript.cpp index 90150b6..c5ca62c 100644 --- a/game/coins/CoinScript.cpp +++ b/game/coins/CoinScript.cpp @@ -5,6 +5,7 @@ #include "../Config.h" #include "../hud/HudScript.h" +#include <crepe/api/AudioSource.h> #include <crepe/api/CircleCollider.h> #include <crepe/api/Sprite.h> @@ -29,6 +30,13 @@ bool CoinScript::on_collision(const CollisionEvent & collisionData) { .active = false; this->amount++; + + AudioSource & audio = this->get_components_by_id<AudioSource>( + collisionData.info.other.metadata.game_object_id + ) + .front(); + audio.play(); + return false; } diff --git a/game/coins/CoinSubScene.cpp b/game/coins/CoinSubScene.cpp index 2c9feb6..3bd6641 100644 --- a/game/coins/CoinSubScene.cpp +++ b/game/coins/CoinSubScene.cpp @@ -39,6 +39,6 @@ int CoinSubScene::create(Scene & scn, int coin_counter) { .looping = true, } ); - coin.add_component<AudioSource>(Asset {"asset/sfx/coin_pickup_1.ogg"}); + coin.add_component<AudioSource>(Asset {"asset/sfx/coin_pickup_1.ogg"}).volume = 3; return coin_counter; } |