diff options
Diffstat (limited to 'game/coins/CoinScript.cpp')
-rw-r--r-- | game/coins/CoinScript.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/game/coins/CoinScript.cpp b/game/coins/CoinScript.cpp index 3d18780..3a2b5b0 100644 --- a/game/coins/CoinScript.cpp +++ b/game/coins/CoinScript.cpp @@ -11,25 +11,35 @@ using namespace crepe; using namespace std; -bool CoinScript::on_collision(const CollisionEvent & collisionData){ - if(collisionData.info.other.metadata.tag != "coin") return false; - this->get_components_by_name<Sprite>(collisionData.info.other.metadata.name).front().get().active = false; - this->get_components_by_name<CircleCollider>(collisionData.info.other.metadata.name).front().get().active = false; +bool CoinScript::on_collision(const CollisionEvent & collisionData) { + if (collisionData.info.other.metadata.tag != "coin") return false; + this->get_components_by_name<Sprite>(collisionData.info.other.metadata.name) + .front() + .get() + .active + = false; + this->get_components_by_name<CircleCollider>(collisionData.info.other.metadata.name) + .front() + .get() + .active + = false; this->amount++; return false; } -void CoinScript::init(){ - this->subscribe<CollisionEvent>([this](const CollisionEvent & ev) -> bool { return this->on_collision(ev); }); +void CoinScript::init() { + this->subscribe<CollisionEvent>([this](const CollisionEvent & ev) -> bool { + return this->on_collision(ev); + }); } void CoinScript::fixed_update(crepe::duration_t dt) { - this->trigger_event(GetCoinEvent{ + this->trigger_event(GetCoinEvent { .amount_of_coins = this->amount, }); } -bool CoinScript::save(){ +bool CoinScript::save() { SaveManager & savemgr = this->get_save_manager(); savemgr.set(TOTAL_COINS_RUN, this->amount); return false; |