diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 13:52:22 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 13:52:22 +0100 |
commit | 1413beea3b506b15b9f0080cec29c745d1ef88da (patch) | |
tree | f09efac3543adb16ea21b1d04d2c2cd4fb181d69 /game/player | |
parent | 1e25ce23534c1dcc7bebfc9fe33c1b587f15643a (diff) |
pooling fix
Diffstat (limited to 'game/player')
-rw-r--r-- | game/player/PlayerBulletPool.cpp | 5 | ||||
-rw-r--r-- | game/player/PlayerBulletSubScene.cpp | 4 | ||||
-rw-r--r-- | game/player/PlayerBulletSubScene.h | 2 |
3 files changed, 6 insertions, 5 deletions
diff --git a/game/player/PlayerBulletPool.cpp b/game/player/PlayerBulletPool.cpp index 63ef346..4cd115e 100644 --- a/game/player/PlayerBulletPool.cpp +++ b/game/player/PlayerBulletPool.cpp @@ -4,5 +4,8 @@ using namespace std; void PlayerBulletPool::create_bullets(crepe::Scene & scn) { PlayerBulletSubScene bullet; - while(bullet.create(scn) < this->MAXIMUM_AMOUNT); + int amount = 0; + while (amount < this->MAXIMUM_AMOUNT) { + amount = bullet.create(scn, amount); + } } diff --git a/game/player/PlayerBulletSubScene.cpp b/game/player/PlayerBulletSubScene.cpp index 4ad236c..96c6b9a 100644 --- a/game/player/PlayerBulletSubScene.cpp +++ b/game/player/PlayerBulletSubScene.cpp @@ -17,9 +17,7 @@ #include "PlayerBulletScript.h" using namespace crepe; using namespace std; -int PlayerBulletSubScene::create(Scene & scn){ - vec2 size = {20, 20}; - static int counter = 0; +int PlayerBulletSubScene::create(Scene & scn,int counter){ string unique_name = "player_bullet_" + to_string(counter++); GameObject player_bullet = scn.new_object(unique_name.c_str(),"player_bullet",vec2{0,-850},0,1); diff --git a/game/player/PlayerBulletSubScene.h b/game/player/PlayerBulletSubScene.h index 4b44dc4..425d554 100644 --- a/game/player/PlayerBulletSubScene.h +++ b/game/player/PlayerBulletSubScene.h @@ -6,5 +6,5 @@ class Scene; class PlayerBulletSubScene { public: - int create(crepe::Scene & scn); + int create(crepe::Scene & scn,int counter); }; |