aboutsummaryrefslogtreecommitdiff
path: root/game/scheduler
diff options
context:
space:
mode:
authorheavydemon21 <48092678+heavydemon21@users.noreply.github.com>2025-01-10 19:35:08 +0100
committerGitHub <noreply@github.com>2025-01-10 19:35:08 +0100
commitb9d00961a8894356c7cff7597de424a12d2841a6 (patch)
treeaa033307a742df0c22131482858749bcf480ba38 /game/scheduler
parent20f6f8ddf013e5d18770bd0a01474a845843bdd7 (diff)
parentf3413f3d0fbffee0cc363096cd873a8be766ad64 (diff)
Merge pull request #123 from lonkaars/wouter/game-improvements
some extra features
Diffstat (limited to 'game/scheduler')
-rw-r--r--game/scheduler/ObjectsScheduler.cpp43
-rw-r--r--game/scheduler/ObjectsScheduler.h2
2 files changed, 41 insertions, 4 deletions
diff --git a/game/scheduler/ObjectsScheduler.cpp b/game/scheduler/ObjectsScheduler.cpp
index 36bf901..7f58c79 100644
--- a/game/scheduler/ObjectsScheduler.cpp
+++ b/game/scheduler/ObjectsScheduler.cpp
@@ -4,6 +4,7 @@
#include "../Config.h"
#include "../Random.h"
+#include "../enemy/EnemyScript.h"
#include "../missile/SpawnEvent.h"
#include "api/Rigidbody.h"
#include "api/Transform.h"
@@ -11,18 +12,52 @@
#include "prefab/ZapperPoolSubScene.h"
using namespace crepe;
+
void ObjectsScheduler::preset_0() {
+ for (int i = 0; i < this->amount_of_boss_fights; i++) {
+ this->trigger_event<MissileSpawnEvent>(MissileSpawnEvent {});
+ }
+ if (this->amount_of_boss_fights >= 1) {
+ this->trigger_event<BattleStartEvent>(BattleStartEvent {
+ .num_enemies = Random::i(this->amount_of_boss_fights, 0),
+ .battle = false,
+ });
+ }
+}
+
+void ObjectsScheduler::preset_1() {
trigger_event<MissileSpawnEvent>(MissileSpawnEvent {});
- trigger_event<MissileSpawnEvent>(MissileSpawnEvent {});
+ if (this->amount_of_boss_fights >= 3) {
+ this->trigger_event<BattleStartEvent>(BattleStartEvent {
+ .num_enemies = Random::i(1, 0),
+ .battle = false,
+ });
+ }
}
-void ObjectsScheduler::preset_1() { trigger_event<MissileSpawnEvent>(MissileSpawnEvent {}); }
-void ObjectsScheduler::preset_2() { trigger_event<CreateZapperEvent>(CreateZapperEvent {}); }
+
+void ObjectsScheduler::preset_2() {
+ trigger_event<CreateZapperEvent>(CreateZapperEvent {});
+ if (this->amount_of_boss_fights >= 2) {
+ this->trigger_event<BattleStartEvent>(BattleStartEvent {
+ .num_enemies = Random::i(2, 1),
+ .battle = false,
+ });
+ }
+}
+
void ObjectsScheduler::preset_3() { trigger_event<CreateZapperEvent>(CreateZapperEvent {}); }
+
void ObjectsScheduler::preset_4() {}
+
void ObjectsScheduler::boss_fight_1() {
this->get_components_by_name<Rigidbody>("camera").front().get().data.linear_velocity.x = 0;
this->get_components_by_name<Rigidbody>("player").front().get().data.linear_velocity.x = 0;
- this->trigger_event<BattleStartEvent>(BattleStartEvent {.num_enemies = 2});
+
+ this->amount_of_boss_fights++;
+ this->trigger_event<BattleStartEvent>(BattleStartEvent {
+ .num_enemies = amount_of_boss_fights,
+ .battle = true,
+ });
RefVector<Rigidbody> rb_back_forest
= this->get_components_by_tag<Rigidbody>("forest_background");
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();