diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2025-01-07 14:06:45 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2025-01-07 14:06:45 +0100 |
commit | 41f890863706ee8ede43021fe83b776b638a18b7 (patch) | |
tree | 4ee74df7e60c8c22c61a1748dd648dda2783b21f /game/coins | |
parent | bc66e7195c80facca244f933b882011e5e81fa3c (diff) |
fixed coins and improved coin
Diffstat (limited to 'game/coins')
-rw-r--r-- | game/coins/CoinPool.cpp | 5 | ||||
-rw-r--r-- | game/coins/CoinScript.cpp | 4 | ||||
-rw-r--r-- | game/coins/CoinSubScene.cpp | 3 | ||||
-rw-r--r-- | game/coins/CoinSubScene.h | 2 | ||||
-rw-r--r-- | game/coins/CoinSystemScript.cpp | 2 | ||||
-rw-r--r-- | game/coins/CoinSystemScript.h | 2 |
6 files changed, 10 insertions, 8 deletions
diff --git a/game/coins/CoinPool.cpp b/game/coins/CoinPool.cpp index 59b987c..439b3b3 100644 --- a/game/coins/CoinPool.cpp +++ b/game/coins/CoinPool.cpp @@ -8,6 +8,9 @@ using namespace crepe; using namespace std; void CoinPool::create_coins(crepe::Scene & scn) { + int amount = 0; CoinSubScene coin; - while(coin.create(scn) < this->MAXIMUM_AMOUNT); + while(amount < this->MAXIMUM_AMOUNT){ + amount = coin.create(scn,amount); + } } diff --git a/game/coins/CoinScript.cpp b/game/coins/CoinScript.cpp index 5960446..a3ee3b9 100644 --- a/game/coins/CoinScript.cpp +++ b/game/coins/CoinScript.cpp @@ -10,11 +10,11 @@ using namespace crepe; using namespace std; bool CoinScript::on_collision(const CollisionEvent & collisionData){ - if(collisionData.info.other.metadata.tag != "coin") return true; + 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 true; + return false; } void CoinScript::init(){ diff --git a/game/coins/CoinSubScene.cpp b/game/coins/CoinSubScene.cpp index 72319ca..9c9caa3 100644 --- a/game/coins/CoinSubScene.cpp +++ b/game/coins/CoinSubScene.cpp @@ -11,10 +11,9 @@ using namespace crepe; using namespace std; -int CoinSubScene::create(Scene & scn){ +int CoinSubScene::create(Scene & scn,int coin_counter){ vec2 size = {20, 20}; - static int coin_counter = 0; string unique_name = "coin_" + to_string(coin_counter++); GameObject coin = scn.new_object(unique_name.c_str(),"coin",vec2{650,0},0,1); diff --git a/game/coins/CoinSubScene.h b/game/coins/CoinSubScene.h index f85f427..ddb6450 100644 --- a/game/coins/CoinSubScene.h +++ b/game/coins/CoinSubScene.h @@ -8,5 +8,5 @@ class Scene; class CoinSubScene { public: - int create(crepe::Scene & scn); + int create(crepe::Scene & scn,int coin_counter); }; diff --git a/game/coins/CoinSystemScript.cpp b/game/coins/CoinSystemScript.cpp index c9c301e..573c825 100644 --- a/game/coins/CoinSystemScript.cpp +++ b/game/coins/CoinSystemScript.cpp @@ -9,7 +9,7 @@ using namespace crepe; using namespace std; -std::vector<CoinSystemScript::CoinData> CoinSystemScript::coin_locations; + void CoinSystemScript::init() { engine.seed(rd()); diff --git a/game/coins/CoinSystemScript.h b/game/coins/CoinSystemScript.h index f558f08..c65b533 100644 --- a/game/coins/CoinSystemScript.h +++ b/game/coins/CoinSystemScript.h @@ -49,7 +49,7 @@ private: static constexpr float SPAWN_DISTANCE = 600; static constexpr float DESPAWN_DISTANCE = 600; static constexpr float SPAWN_AREA = 50; - static std::vector<CoinData> coin_locations; + std::vector<CoinData> coin_locations; private: // preset one settings // ***** ***** |