diff options
author | Max-001 <80035972+Max-001@users.noreply.github.com> | 2025-01-10 18:51:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-10 18:51:37 +0100 |
commit | f3413f3d0fbffee0cc363096cd873a8be766ad64 (patch) | |
tree | aa033307a742df0c22131482858749bcf480ba38 | |
parent | 7aa07561a52016007ff852acefa4db68260f0f1e (diff) | |
parent | 842ed3c20d923a84b5a267169b15c2170f97f099 (diff) |
Merge pull request #130 from lonkaars/max/game2
Max/game2
-rw-r--r-- | game/player/PlayerEndScript.cpp | 3 | ||||
-rw-r--r-- | game/player/PlayerSubScene.cpp | 25 | ||||
-rw-r--r-- | game/scheduler/ObjectsScheduler.cpp | 57 | ||||
-rw-r--r-- | game/scheduler/ObjectsScheduler.h | 2 | ||||
-rw-r--r-- | src/crepe/api/Config.h | 2 |
5 files changed, 66 insertions, 23 deletions
diff --git a/game/player/PlayerEndScript.cpp b/game/player/PlayerEndScript.cpp index 4ae813f..62fd350 100644 --- a/game/player/PlayerEndScript.cpp +++ b/game/player/PlayerEndScript.cpp @@ -92,8 +92,9 @@ bool PlayerEndScript::on_collision(const crepe::CollisionEvent & ev) { jump++; } - if (rb_player.data.linear_velocity.x < 5 && jump >= 3) { + if (rb_player.data.linear_velocity.x < 5 && jump == 3) { this->trigger_event<EndGameEvent>(); + jump++; } return false; diff --git a/game/player/PlayerSubScene.cpp b/game/player/PlayerSubScene.cpp index 4d17c47..d0142e0 100644 --- a/game/player/PlayerSubScene.cpp +++ b/game/player/PlayerSubScene.cpp @@ -5,8 +5,8 @@ #include "../Config.h" #include "../coins/CoinScript.h" -#include "api/Asset.h" +#include <crepe/ValueBroker.h> #include <crepe/api/Animator.h> #include <crepe/api/AudioSource.h> #include <crepe/api/BoxCollider.h> @@ -16,6 +16,7 @@ #include <crepe/api/Scene.h> #include <crepe/api/Script.h> #include <crepe/api/Sprite.h> +#include <crepe/manager/SaveManager.h> #include <crepe/types.h> using namespace crepe; @@ -24,7 +25,23 @@ using namespace std; PlayerSubScene::PlayerSubScene(Scene & scn) { GameObject player = scn.new_object("player", "player", vec2(-100, 200)); - Asset player_bullet {"asset/other_effects/effect_smgbullet.png"}; + SaveManager & save = scn.get_save_manager(); + ValueBroker<int> particle_type = save.get<int>(JETPACK_PARTICLES, 0); + + string player_bullet_string; + string player_bullet_x2_string; + string player_shell_string; + if (particle_type.get() == 0) { + player_bullet_string = "asset/other_effects/effect_smgbullet.png"; + player_bullet_x2_string = "asset/other_effects/effect_smgbullet_x2.png"; + player_shell_string = "asset/other_effects/effect_rocketmgshell_TVOS.png"; + } else { + player_bullet_string = "asset/background/aquarium/bubble.png"; + player_bullet_x2_string = "asset/background/aquarium/bubble.png"; + player_shell_string = "asset/background/aquarium/bubble.png"; + } + + Asset player_bullet {player_bullet_string}; Sprite & player_bullet_sprite = player.add_component<Sprite>( player_bullet, Sprite::Data { @@ -45,7 +62,7 @@ PlayerSubScene::PlayerSubScene(Scene & scn) { .reset_on_exit = true, }, }); - Asset player_bullet_x2 {"asset/other_effects/effect_smgbullet_x2.png"}; + Asset player_bullet_x2 {player_bullet_x2_string}; Sprite & player_bullet_x2_sprite = player.add_component<Sprite>( player_bullet_x2, Sprite::Data { @@ -66,7 +83,7 @@ PlayerSubScene::PlayerSubScene(Scene & scn) { .reset_on_exit = true, }, }); - Asset player_shell {"asset/other_effects/effect_rocketmgshell_TVOS.png"}; + Asset player_shell {player_shell_string}; Sprite & player_shell_sprite = player.add_component<Sprite>( player_shell, Sprite::Data { diff --git a/game/scheduler/ObjectsScheduler.cpp b/game/scheduler/ObjectsScheduler.cpp index c33c707..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>(MissileSpawnEvent {}); - trigger_event<MissileSpawnEvent>(MissileSpawnEvent {}); - this->trigger_event<BattleStartEvent>(BattleStartEvent { - .num_enemies = Random::i(2, 0), - .battle = false, - }); + 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 {}); - this->trigger_event<BattleStartEvent>(BattleStartEvent { - .num_enemies = Random::i(2, 1), - .battle = false, - }); + if (this->amount_of_boss_fights >= 3) { + this->trigger_event<BattleStartEvent>(BattleStartEvent { + .num_enemies = Random::i(1, 0), + .battle = false, + }); + } } + void ObjectsScheduler::preset_2() { trigger_event<CreateZapperEvent>(CreateZapperEvent {}); - this->trigger_event<BattleStartEvent>(BattleStartEvent { - .num_enemies = Random::i(2, 1), - .battle = false, - }); + 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->amount_of_boss_fights++; this->trigger_event<BattleStartEvent>(BattleStartEvent { - .num_enemies = 5, + .num_enemies = amount_of_boss_fights, .battle = true, }); @@ -57,10 +72,18 @@ bool ObjectsScheduler::boss_fight_1_event() { this->get_components_by_name<Rigidbody>("player").front().get().data.linear_velocity.x = PLAYER_SPEED * 0.02; + bool first = true; RefVector<Rigidbody> rb_back_forest = this->get_components_by_tag<Rigidbody>("forest_background"); - rb_back_forest.front().get().data.linear_velocity.x = 30; - rb_back_forest.back().get().data.linear_velocity.x = 40; + for (Rigidbody & rb : rb_back_forest) { + if (first == true) { + rb.data.linear_velocity.x = 30; + first = false; + } else { + rb.data.linear_velocity.x = 40; + first = true; + } + } return false; } 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(); diff --git a/src/crepe/api/Config.h b/src/crepe/api/Config.h index 7475528..65a8302 100644 --- a/src/crepe/api/Config.h +++ b/src/crepe/api/Config.h @@ -86,7 +86,7 @@ struct Config final { * This config option is the font size at which all fonts will be loaded initially. * */ - unsigned int size = 500; + unsigned int size = 100; } font; //! Configuration for click tolerance. struct { |