From 842ed3c20d923a84b5a267169b15c2170f97f099 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Fri, 10 Jan 2025 17:37:36 +0100 Subject: Spawn more enemies when game is further --- game/scheduler/ObjectsScheduler.cpp | 45 ++++++++++++++++++++++++------------- game/scheduler/ObjectsScheduler.h | 2 ++ 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/game/scheduler/ObjectsScheduler.cpp b/game/scheduler/ObjectsScheduler.cpp index 0839fe5..7f58c79 100644 --- a/game/scheduler/ObjectsScheduler.cpp +++ b/game/scheduler/ObjectsScheduler.cpp @@ -12,35 +12,50 @@ #include "prefab/ZapperPoolSubScene.h" using namespace crepe; + void ObjectsScheduler::preset_0() { - trigger_event(MissileSpawnEvent {}); - trigger_event(MissileSpawnEvent {}); - this->trigger_event(BattleStartEvent { - .num_enemies = Random::i(2, 0), - .battle = false, - }); + for (int i = 0; i < this->amount_of_boss_fights; i++) { + this->trigger_event(MissileSpawnEvent {}); + } + if (this->amount_of_boss_fights >= 1) { + this->trigger_event(BattleStartEvent { + .num_enemies = Random::i(this->amount_of_boss_fights, 0), + .battle = false, + }); + } } + void ObjectsScheduler::preset_1() { trigger_event(MissileSpawnEvent {}); - this->trigger_event(BattleStartEvent { - .num_enemies = Random::i(2, 1), - .battle = false, - }); + if (this->amount_of_boss_fights >= 3) { + this->trigger_event(BattleStartEvent { + .num_enemies = Random::i(1, 0), + .battle = false, + }); + } } + void ObjectsScheduler::preset_2() { trigger_event(CreateZapperEvent {}); - this->trigger_event(BattleStartEvent { - .num_enemies = Random::i(2, 1), - .battle = false, - }); + if (this->amount_of_boss_fights >= 2) { + this->trigger_event(BattleStartEvent { + .num_enemies = Random::i(2, 1), + .battle = false, + }); + } } + void ObjectsScheduler::preset_3() { trigger_event(CreateZapperEvent {}); } + void ObjectsScheduler::preset_4() {} + void ObjectsScheduler::boss_fight_1() { this->get_components_by_name("camera").front().get().data.linear_velocity.x = 0; this->get_components_by_name("player").front().get().data.linear_velocity.x = 0; + + this->amount_of_boss_fights++; this->trigger_event(BattleStartEvent { - .num_enemies = 5, + .num_enemies = amount_of_boss_fights, .battle = true, }); diff --git a/game/scheduler/ObjectsScheduler.h b/game/scheduler/ObjectsScheduler.h index bd0701b..7ada8e1 100644 --- a/game/scheduler/ObjectsScheduler.h +++ b/game/scheduler/ObjectsScheduler.h @@ -16,6 +16,8 @@ private: int obstacle_interval = 350; int start_offset = 1300; + int amount_of_boss_fights = 0; + private: void preset_0(); void preset_1(); -- cgit v1.2.3