From d65e0ff31a75230fd1c18eaeab9cb25ab2b9c82a Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Fri, 3 Jan 2025 16:36:43 +0100 Subject: save amount of coins --- game/coins/CoinScript.cpp | 4 ++++ game/coins/CoinScript.h | 1 + 2 files changed, 5 insertions(+) (limited to 'game/coins') diff --git a/game/coins/CoinScript.cpp b/game/coins/CoinScript.cpp index f067f04..862e7f9 100644 --- a/game/coins/CoinScript.cpp +++ b/game/coins/CoinScript.cpp @@ -1,6 +1,7 @@ #include "CoinScript.h" #include "api/CircleCollider.h" #include "api/Sprite.h" +#include "manager/SaveManager.h" using namespace crepe; using namespace std; @@ -10,6 +11,9 @@ bool CoinScript::on_collision(const CollisionEvent & collisionData){ //collide with player this->get_component().active = false; this->get_component().active = false; + SaveManager & savemgr = this->get_save_manager(); + int amount = savemgr.get(COIN_GAME_AMOUNT,0).get() + 1; + savemgr.set(COIN_GAME_AMOUNT, amount); return true; } diff --git a/game/coins/CoinScript.h b/game/coins/CoinScript.h index 6c52733..3fcee6d 100644 --- a/game/coins/CoinScript.h +++ b/game/coins/CoinScript.h @@ -7,4 +7,5 @@ public: void init() override; bool on_collision(const crepe::CollisionEvent & collisionData); static constexpr const char* PLAYER_NAME = "player"; + static constexpr const char* COIN_GAME_AMOUNT = "coin_game_amount"; }; -- cgit v1.2.3