aboutsummaryrefslogtreecommitdiff
path: root/game/coins/CoinScript.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-08 14:52:06 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-08 14:52:06 +0100
commitfbd7c84e13381922bf327e20c1abc65337142445 (patch)
treef48bcf5527b9df45cdbc2ba4ab2dab4ab8ea921c /game/coins/CoinScript.cpp
parentd989c1c51bf4d4fbb301493e73bc77e1873143b2 (diff)
parent91366375a7b2a9be670e4842604512254a9c116e (diff)
Merge branch 'master' into niels/game
Diffstat (limited to 'game/coins/CoinScript.cpp')
-rw-r--r--game/coins/CoinScript.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/game/coins/CoinScript.cpp b/game/coins/CoinScript.cpp
index 90150b6..514f4de 100644
--- a/game/coins/CoinScript.cpp
+++ b/game/coins/CoinScript.cpp
@@ -5,6 +5,8 @@
#include "../Config.h"
#include "../hud/HudScript.h"
+#include <crepe/api/Animator.h>
+#include <crepe/api/AudioSource.h>
#include <crepe/api/CircleCollider.h>
#include <crepe/api/Sprite.h>
@@ -29,6 +31,24 @@ 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();
+
+ this->get_components_by_name<Sprite>(collisionData.info.other.metadata.name)
+ .back()
+ .get()
+ .active
+ = true;
+ this->get_components_by_name<Animator>(collisionData.info.other.metadata.name)
+ .back()
+ .get()
+ .active
+ = true;
+
return false;
}