From 016b36b6d340be958bb047ca5f26dd54aa658c88 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Wed, 8 Jan 2025 12:43:54 +0100 Subject: battlescript battle won working --- game/enemy/BattleScript.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'game/enemy/BattleScript.cpp') diff --git a/game/enemy/BattleScript.cpp b/game/enemy/BattleScript.cpp index 463ddf3..1d263a3 100644 --- a/game/enemy/BattleScript.cpp +++ b/game/enemy/BattleScript.cpp @@ -1,4 +1,3 @@ -#include #include "BattleScript.h" #include #include "EnemyScript.h" @@ -8,10 +7,7 @@ #include "EnemyScript.h" using namespace std; using namespace crepe; -// stop player movement -// spawn enemies -// resume game once enemies are defeated -// optional: spawn lazers during fight + BattleScript::BattleScript(){ engine.seed(rd()); } @@ -24,6 +20,7 @@ void BattleScript::init(){ }); } void BattleScript::fixed_update(duration_t dt){ + if(!battle_active) return; bool enemies_alive = false; RefVector enemy_scripts = this->get_components_by_tag("enemy"); @@ -33,10 +30,12 @@ void BattleScript::fixed_update(duration_t dt){ } } if(!enemies_alive){ + this->battle_active = false; this->trigger_event(); } } bool BattleScript::create_battle(const BattleStartEvent& e){ + this->battle_active = true; RefVector enemy_scripts = this->get_components_by_tag("enemy"); std::uniform_real_distribution dist(10,30); for(int i = 0; i < e.num_enemies;i++){ -- cgit v1.2.3