From eb3d9ec9baa0b95b95d741a0615adaf4c8c1d3c0 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 8 Jan 2025 16:32:03 +0100 Subject: added preset with nothing --- game/missile/MissileSubScene.cpp | 4 +++- game/missile/SpawnEvent.h | 2 +- game/scheduler/ObjectsScheduler.cpp | 21 ++++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) (limited to 'game') diff --git a/game/missile/MissileSubScene.cpp b/game/missile/MissileSubScene.cpp index db49f88..59d8221 100644 --- a/game/missile/MissileSubScene.cpp +++ b/game/missile/MissileSubScene.cpp @@ -65,6 +65,7 @@ void MissileSubScene::create(crepe::Scene & scn) { missle.add_component( missle_sprite, ivec2 {32, 32}, uvec2 {4, 1}, Animator::Data { + .fps = 15, .looping = true, } ); @@ -72,6 +73,7 @@ void MissileSubScene::create(crepe::Scene & scn) { missle.add_component( missle_thruster_sprite, ivec2 {64, 64}, uvec2 {4, 2}, Animator::Data { + .fps = 15, .looping = true, } ); @@ -86,7 +88,7 @@ void MissileSubScene::create(crepe::Scene & scn) { missile_explosion_sprite.active = false; explosion_anim.active = false; - std::uniform_int_distribution<> dist(140, 200); + std::uniform_int_distribution<> dist(200, 250); missle.add_component(Rigidbody::Data { .body_type = Rigidbody::BodyType::KINEMATIC, .max_linear_velocity = static_cast(dist(gen)), diff --git a/game/missile/SpawnEvent.h b/game/missile/SpawnEvent.h index ce301fd..58293d7 100644 --- a/game/missile/SpawnEvent.h +++ b/game/missile/SpawnEvent.h @@ -9,7 +9,7 @@ struct MissileSpawnEvent : public crepe::Event {}; class MissileSpawnEventHandler : public crepe::Script { private: - static constexpr int MISSILE_OFFSET = VIEWPORT_X / 1.8; + static constexpr int MISSILE_OFFSET = VIEWPORT_X; static constexpr int RANGE = GAME_HEIGHT / 4; static constexpr int MIN_RANGE = -RANGE; static constexpr int MAX_RANGE = RANGE; diff --git a/game/scheduler/ObjectsScheduler.cpp b/game/scheduler/ObjectsScheduler.cpp index 02d84c1..60e3f47 100644 --- a/game/scheduler/ObjectsScheduler.cpp +++ b/game/scheduler/ObjectsScheduler.cpp @@ -2,8 +2,8 @@ #include "ObjectsScheduler.h" -#include "../Random.h" #include "../Config.h" +#include "../Random.h" #include "../missile/SpawnEvent.h" #include "api/Rigidbody.h" #include "api/Transform.h" @@ -11,20 +11,25 @@ #include "prefab/ZapperPoolSubScene.h" using namespace crepe; -void ObjectsScheduler::preset_0() { trigger_event(MissileSpawnEvent {}); } +void ObjectsScheduler::preset_0() { + trigger_event(MissileSpawnEvent {}); + trigger_event(MissileSpawnEvent {}); +} void ObjectsScheduler::preset_1() { trigger_event(MissileSpawnEvent {}); } void ObjectsScheduler::preset_2() { trigger_event(CreateZapperEvent {}); } -void ObjectsScheduler::preset_3() {} +void ObjectsScheduler::preset_3() { trigger_event(CreateZapperEvent {}); } void ObjectsScheduler::preset_4() {} -void ObjectsScheduler::boss_fight_1() { +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->trigger_event(BattleStartEvent{.num_enemies = 2}); + this->trigger_event(BattleStartEvent {.num_enemies = 2}); } bool ObjectsScheduler::boss_fight_1_event() { - this->get_components_by_name("camera").front().get().data.linear_velocity.x = PLAYER_SPEED * 0.02; - this->get_components_by_name("player").front().get().data.linear_velocity.x = PLAYER_SPEED * 0.02; + this->get_components_by_name("camera").front().get().data.linear_velocity.x + = PLAYER_SPEED * 0.02; + this->get_components_by_name("player").front().get().data.linear_velocity.x + = PLAYER_SPEED * 0.02; return false; } @@ -32,6 +37,8 @@ void ObjectsScheduler::init() { this->obstacles.push_back([this]() { preset_0(); }); this->obstacles.push_back([this]() { preset_1(); }); this->obstacles.push_back([this]() { preset_2(); }); + this->obstacles.push_back([this]() { preset_3(); }); + this->obstacles.push_back([this]() { preset_4(); }); this->obstacles.push_back([this]() { boss_fight_1(); }); -- cgit v1.2.3 From 9ae8d8f860146c1777e55dec7bd455aa16351375 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 8 Jan 2025 16:32:33 +0100 Subject: make format --- game/GameScene.cpp | 2 +- game/enemy/EnemyBulletSubScene.cpp | 2 +- game/enemy/EnemyScript.cpp | 7 +++---- game/enemy/EnemySubScene.cpp | 5 ++--- game/menus/shop/ShopMenuScene.cpp | 1 - game/player/PlayerBulletSubScene.cpp | 2 +- game/scheduler/ObjectsScheduler.h | 6 +----- game/workers/CollisionScript.cpp | 3 ++- 8 files changed, 11 insertions(+), 17 deletions(-) (limited to 'game') diff --git a/game/GameScene.cpp b/game/GameScene.cpp index 34b0fcb..3ae64fb 100644 --- a/game/GameScene.cpp +++ b/game/GameScene.cpp @@ -20,8 +20,8 @@ #include "player/PlayerBulletPool.h" #include "player/PlayerBulletSubScene.h" #include "player/PlayerSubScene.h" -#include "scheduler/ObjectsScheduler.h" #include "prefab/ZapperPoolSubScene.h" +#include "scheduler/ObjectsScheduler.h" #include "workers/WorkersSubScene.h" #include diff --git a/game/enemy/EnemyBulletSubScene.cpp b/game/enemy/EnemyBulletSubScene.cpp index 5c31f1d..ad2ca9d 100644 --- a/game/enemy/EnemyBulletSubScene.cpp +++ b/game/enemy/EnemyBulletSubScene.cpp @@ -30,7 +30,7 @@ int EnemyBulletSubScene::create(Scene & scn, int counter) { .linear_velocity = vec2 {-250, 0}, .kinematic_collision = false, - .collision_layers = {COLL_LAY_MISSILE,COLL_LAY_ZAPPER}, + .collision_layers = {COLL_LAY_MISSILE, COLL_LAY_ZAPPER}, .collision_layer = COLL_LAY_BULLET }); bullet_body.active = false; diff --git a/game/enemy/EnemyScript.cpp b/game/enemy/EnemyScript.cpp index 8cf8b80..5c03539 100644 --- a/game/enemy/EnemyScript.cpp +++ b/game/enemy/EnemyScript.cpp @@ -4,12 +4,11 @@ #include "EnemyConfig.h" #include #include +#include #include #include #include #include -#include -#include #include #include using namespace crepe; @@ -86,7 +85,7 @@ bool EnemyScript::on_collide(const CollisionEvent & e) { if (e.info.other.metadata.tag == "player_bullet") { this->despawn_enemy(); } - Animator& body_animator = this->get_components().front(); + Animator & body_animator = this->get_components().front(); body_animator.data.col = 2; //body_animator.play(); BehaviorScript & enemy_script = this->get_component(); @@ -115,7 +114,7 @@ void EnemyScript::shoot(const vec2 & location, float angle) { = this->get_components_by_id(bullet_pos.game_object_id).front(); bullet_collider.active = true; bullet_body.active = true; - AudioSource& audio = this->get_component(); + AudioSource & audio = this->get_component(); audio.play(); return; } diff --git a/game/enemy/EnemySubScene.cpp b/game/enemy/EnemySubScene.cpp index 8316db9..607b9a9 100644 --- a/game/enemy/EnemySubScene.cpp +++ b/game/enemy/EnemySubScene.cpp @@ -2,13 +2,13 @@ #include #include +#include #include #include #include #include #include #include -#include #include #include "../Config.h" @@ -91,8 +91,7 @@ int EnemySubScene::create(Scene & scn, int enemy_counter) { .looping = true, } ); - enemy.add_component(Asset("asset/sfx/bike_gun_2.ogg")).volume - = 0.1; + enemy.add_component(Asset("asset/sfx/bike_gun_2.ogg")).volume = 0.1; AI & ai_component = enemy.add_component(3000); ai_component.path_follow_on(); BehaviorScript & enemy_script diff --git a/game/menus/shop/ShopMenuScene.cpp b/game/menus/shop/ShopMenuScene.cpp index 5ada0d3..d1ea81d 100644 --- a/game/menus/shop/ShopMenuScene.cpp +++ b/game/menus/shop/ShopMenuScene.cpp @@ -6,7 +6,6 @@ #include "../ButtonSubScene.h" #include "../MenusConfig.h" #include "types.h" -#include "../../Config.h" #include #include diff --git a/game/player/PlayerBulletSubScene.cpp b/game/player/PlayerBulletSubScene.cpp index 2d237de..795747b 100644 --- a/game/player/PlayerBulletSubScene.cpp +++ b/game/player/PlayerBulletSubScene.cpp @@ -27,7 +27,7 @@ int PlayerBulletSubScene::create(Scene & scn, int counter) { .linear_velocity = vec2 {400, 0}, .angular_velocity = 10, .kinematic_collision = false, - .collision_layers = {COLL_LAY_ENEMY,COLL_LAY_ZAPPER}, + .collision_layers = {COLL_LAY_ENEMY, COLL_LAY_ZAPPER}, .collision_layer = COLL_LAY_PLAYER_BULLET, diff --git a/game/scheduler/ObjectsScheduler.h b/game/scheduler/ObjectsScheduler.h index 56d72cb..bd0701b 100644 --- a/game/scheduler/ObjectsScheduler.h +++ b/game/scheduler/ObjectsScheduler.h @@ -1,17 +1,14 @@ #pragma once - - #include "api/Script.h" #include #include - class ObjectsScheduler : public crepe::Script { private: std::vector> obstacles; - + int last_boss_check = 0; int last_obstacle_check = 0; @@ -32,5 +29,4 @@ private: public: void init(); void fixed_update(crepe::duration_t dt); - }; diff --git a/game/workers/CollisionScript.cpp b/game/workers/CollisionScript.cpp index 625044d..372bfec 100644 --- a/game/workers/CollisionScript.cpp +++ b/game/workers/CollisionScript.cpp @@ -49,7 +49,8 @@ bool CollisionScript::on_collision(const CollisionEvent & ev) { bs_panic.active = false; return false; - } else if (ev.info.other.metadata.tag == "missile" || ev.info.other.metadata.tag == "enemy_bullet") { + } else if (ev.info.other.metadata.tag == "missile" + || ev.info.other.metadata.tag == "enemy_bullet") { for (Animator & anim : animators) { anim.active = false; anim.set_anim(3); -- cgit v1.2.3