diff options
| author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2025-01-08 15:13:08 +0100 | 
|---|---|---|
| committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2025-01-08 15:13:08 +0100 | 
| commit | 17a587ee6ded6d51c678fcd89bf0d28dc60db43d (patch) | |
| tree | bcf8685ac2f133878db070beb3b20c6b4a8dba31 | |
| parent | 714c8798dd0998ea15b1ba697962a97c586457fe (diff) | |
added boss fight, did not work
| -rw-r--r-- | game/GameScene.cpp | 5 | ||||
| -rw-r--r-- | game/scheduler/ObjectsScheduler.cpp | 13 | ||||
| -rw-r--r-- | game/scheduler/ObjectsScheduler.h | 8 | 
3 files changed, 18 insertions, 8 deletions
| diff --git a/game/GameScene.cpp b/game/GameScene.cpp index a255e17..07275ab 100644 --- a/game/GameScene.cpp +++ b/game/GameScene.cpp @@ -8,6 +8,7 @@  #include "background/BackgroundSubScene.h"  #include "enemy/BattleScript.h"  #include "enemy/EnemyBulletPool.h" +#include "enemy/EnemyBulletSubScene.h"  #include "enemy/EnemyPool.h"  #include "enemy/EnemySubScene.h"  #include "hud/HudScript.h" @@ -62,8 +63,8 @@ void GameScene::load_scene() {  	camera.add_component<BehaviorScript>().set_script<SpeedScript>();  	camera.add_component<BehaviorScript>().set_script<ObjectsScheduler>();  	camera.add_component<BehaviorScript>().set_script<MissileSpawnEventHandler>(); -  	camera.add_component<BehaviorScript>().set_script<BattleScript>(); +  	camera.add_component<Rigidbody>(Rigidbody::Data {});  	AI & enemy_path_1 = camera.add_component<AI>(400);  	enemy_path_1.make_oval_path(100, 100, camera.transform.position, 1.5708, true); @@ -73,9 +74,7 @@ void GameScene::load_scene() {  	enemy_path_3.make_oval_path(100, 100, {0, 0}, 1.5708, true);  	// camer.add_component<AI>  	PlayerSubScene player(*this); -  	MissilePool missile_pool(*this); -  	WorkersSubScene workers(*this);  	GameObject floor = new_object("floor", "game_world", vec2(0, 325)); 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); |