From f18635b6c73f753bd38343684134430a5ce9b22c Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Fri, 3 Jan 2025 16:12:14 +0100 Subject: added coins random and menu banner update --- game/coins/CoinScript.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 game/coins/CoinScript.cpp (limited to 'game/coins/CoinScript.cpp') diff --git a/game/coins/CoinScript.cpp b/game/coins/CoinScript.cpp new file mode 100644 index 0000000..f067f04 --- /dev/null +++ b/game/coins/CoinScript.cpp @@ -0,0 +1,19 @@ +#include "CoinScript.h" +#include "api/CircleCollider.h" +#include "api/Sprite.h" + +using namespace crepe; +using namespace std; + +bool CoinScript::on_collision(const CollisionEvent & collisionData){ + if(collisionData.info.other.metadata.name != PLAYER_NAME) return true; + //collide with player + this->get_component().active = false; + this->get_component().active = false; + return true; +} + +void CoinScript::init(){ + subscribe([this](const CollisionEvent & ev) -> bool { return this->on_collision(ev); }); +} + -- cgit v1.2.3