aboutsummaryrefslogtreecommitdiff
path: root/game/scheduler
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-08 15:13:08 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-08 15:13:08 +0100
commit17a587ee6ded6d51c678fcd89bf0d28dc60db43d (patch)
treebcf8685ac2f133878db070beb3b20c6b4a8dba31 /game/scheduler
parent714c8798dd0998ea15b1ba697962a97c586457fe (diff)
added boss fight, did not work
Diffstat (limited to 'game/scheduler')
-rw-r--r--game/scheduler/ObjectsScheduler.cpp13
-rw-r--r--game/scheduler/ObjectsScheduler.h8
2 files changed, 16 insertions, 5 deletions
diff --git a/game/scheduler/ObjectsScheduler.cpp b/game/scheduler/ObjectsScheduler.cpp
index 21465e3..416a8da 100644
--- a/game/scheduler/ObjectsScheduler.cpp
+++ b/game/scheduler/ObjectsScheduler.cpp
@@ -5,6 +5,7 @@
#include "../Random.h"
#include "../missile/SpawnEvent.h"
#include "api/Transform.h"
+#include "enemy/BattleScript.h"
#include "prefab/ZapperPoolSubScene.h"
#include <iostream>
@@ -14,7 +15,12 @@ void ObjectsScheduler::preset_1() { trigger_event<MissileSpawnEvent>(MissileSpaw
void ObjectsScheduler::preset_2() { trigger_event<CreateZapperEvent>(CreateZapperEvent {}); }
void ObjectsScheduler::preset_3() {}
void ObjectsScheduler::preset_4() {}
-void ObjectsScheduler::boss_fight_1() { std::cout << "Boss fight" << std::endl; }
+void ObjectsScheduler::boss_fight_1() { trigger_event<BattleStartEvent>(BattleStartEvent {}); }
+
+bool ObjectsScheduler::boss_fight_1_event() {
+ std::cout << "BATTLE WON" << std::endl;
+ return false;
+}
void ObjectsScheduler::init() {
this->obstacles.push_back([this]() { preset_0(); });
@@ -24,6 +30,9 @@ void ObjectsScheduler::init() {
this->obstacles.push_back([this]() { boss_fight_1(); });
// subscribe to battlewonevent
+ this->subscribe<BattleWonEvent>([this](const BattleWonEvent & ev) -> bool {
+ return this->boss_fight_1_event();
+ });
}
void ObjectsScheduler::fixed_update(duration_t dt) {
@@ -32,7 +41,7 @@ void ObjectsScheduler::fixed_update(duration_t dt) {
int boss_check = (pos_x - this->start_offset) / this->boss_fight_interval;
if (boss_check > this->last_boss_check) {
- this->obstacles[2]();
+ this->obstacles.back()();
this->last_boss_check = boss_check;
}
int obstacle_check = (pos_x - this->start_offset) / this->obstacle_interval;
diff --git a/game/scheduler/ObjectsScheduler.h b/game/scheduler/ObjectsScheduler.h
index 7bc9337..1bd0940 100644
--- a/game/scheduler/ObjectsScheduler.h
+++ b/game/scheduler/ObjectsScheduler.h
@@ -15,11 +15,11 @@ private:
int last_boss_check = 0;
int last_obstacle_check = 0;
- int boss_fight_interval = 2500;
- int obstacle_interval = 300;
+ int boss_fight_interval = 1000;
+ int obstacle_interval = 3000;
int start_offset = 1300;
-
+private:
void preset_0();
void preset_1();
void preset_2();
@@ -27,6 +27,8 @@ private:
void preset_4();
void boss_fight_1();
+ bool boss_fight_1_event();
+
public:
void init();
void fixed_update(crepe::duration_t dt);