aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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";
};