aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2025-01-03 16:36:43 +0100
committerJAROWMR <jarorutjes07@gmail.com>2025-01-03 16:36:43 +0100
commitd65e0ff31a75230fd1c18eaeab9cb25ab2b9c82a (patch)
tree944b8c4755f7159178e136f32a64f96004d582a0 /game
parentf18635b6c73f753bd38343684134430a5ce9b22c (diff)
save amount of coins
Diffstat (limited to 'game')
-rw-r--r--game/coins/CoinScript.cpp4
-rw-r--r--game/coins/CoinScript.h1
2 files changed, 5 insertions, 0 deletions
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<Sprite>().active = false;
this->get_component<CircleCollider>().active = false;
+ SaveManager & savemgr = this->get_save_manager();
+ int amount = savemgr.get<int>(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";
};