diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-09 14:46:30 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-09 14:46:30 +0100 |
commit | 7739a80176cea889ce240d18d354c5174825b25a (patch) | |
tree | e61974e217791cd86f519bf1c4cfd3b082d55166 /game/enemy/BattleScript.cpp | |
parent | 8b32dbc33c434f84b4aab98819147c3b8416ff69 (diff) |
workers during normal sequence working
Diffstat (limited to 'game/enemy/BattleScript.cpp')
-rw-r--r-- | game/enemy/BattleScript.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/game/enemy/BattleScript.cpp b/game/enemy/BattleScript.cpp index 6d96ef6..3eda89e 100644 --- a/game/enemy/BattleScript.cpp +++ b/game/enemy/BattleScript.cpp @@ -1,6 +1,7 @@ #include "BattleScript.h" #include "EnemyScript.h" #include <crepe/api/AI.h> +#include <iostream> #include <crepe/api/BehaviorScript.h> #include <crepe/api/Metadata.h> using namespace std; @@ -28,16 +29,23 @@ void BattleScript::fixed_update(duration_t dt) { } if (!enemies_alive) { this->battle_active = false; + cout << "battle won" << endl; this->trigger_event<BattleWonEvent>(); } } bool BattleScript::create_battle(const BattleStartEvent & e) { - this->battle_active = true; + this->battle_active = e.battle; + this->spawn_enemies(e.num_enemies); + return false; +} +void BattleScript::spawn_enemies(int amount) { RefVector<BehaviorScript> enemy_scripts = this->get_components_by_tag<BehaviorScript>("enemy"); - std::uniform_real_distribution<float> dist(10, 30); - for (int i = 0; i < e.num_enemies; i++) { + std::uniform_real_distribution<float> dist(70, 150); + + for (int i = 0; i < amount; i++) { BehaviorScript & script = enemy_scripts[i]; + if(script.active == true) continue; script.active = true; this->queue_event<SpawnEnemyEvent>( SpawnEnemyEvent { @@ -47,5 +55,4 @@ bool BattleScript::create_battle(const BattleStartEvent & e) { script.game_object_id ); } - return false; } |