From 231d33954dab62e2452eb88e509d2741a8437498 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Wed, 8 Jan 2025 08:57:19 +0100 Subject: Init --- game/workers/CollisionScript.cpp | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 game/workers/CollisionScript.cpp (limited to 'game/workers/CollisionScript.cpp') diff --git a/game/workers/CollisionScript.cpp b/game/workers/CollisionScript.cpp new file mode 100644 index 0000000..9e9b981 --- /dev/null +++ b/game/workers/CollisionScript.cpp @@ -0,0 +1,62 @@ +#include "CollisionScript.h" + +#include +#include +#include + + +using namespace crepe; +using namespace std; + +void CollisionScript::init() { + subscribe([this](const CollisionEvent & ev) -> bool { + return this->on_collision(ev); + }); +} + +bool CollisionScript::on_collision(const CollisionEvent & ev) { + RefVector animators = this->get_components_by_name("player"); + RefVector emitters + = this->get_components_by_name("player"); + + if (ev.info.other.metadata.tag == "zapper") { + for (Animator & anim : animators) { + anim.active = true; + anim.set_anim(4); + anim.data.looping = true; + } + for (ParticleEmitter & emitter : emitters) { + emitter.data.emission_rate = 0; + } + + return true; + } else if (ev.info.other.metadata.tag == "laser") { + for (Animator & anim : animators) { + anim.active = true; + anim.set_anim(4); + anim.data.looping = true; + } + for (ParticleEmitter & emitter : emitters) { + emitter.data.emission_rate = 0; + } + play_scr.active = false; + end_scr.active = true; + + return true; + } else if (ev.info.other.metadata.tag == "missile") { + for (Animator & anim : animators) { + anim.active = true; + anim.set_anim(5); + anim.data.looping = true; + } + for (ParticleEmitter & emitter : emitters) { + emitter.data.emission_rate = 0; + } + play_scr.active = false; + end_scr.active = true; + + return true; + } + + return false; +} -- cgit v1.2.3 From b8ff1dcd4e531c3c858ee09f705cf553e86ed7ff Mon Sep 17 00:00:00 2001 From: Max-001 Date: Wed, 8 Jan 2025 09:07:46 +0100 Subject: Adjusted script --- game/workers/CollisionScript.cpp | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'game/workers/CollisionScript.cpp') diff --git a/game/workers/CollisionScript.cpp b/game/workers/CollisionScript.cpp index 9e9b981..baa058b 100644 --- a/game/workers/CollisionScript.cpp +++ b/game/workers/CollisionScript.cpp @@ -1,9 +1,6 @@ #include "CollisionScript.h" #include -#include -#include - using namespace crepe; using namespace std; @@ -15,9 +12,7 @@ void CollisionScript::init() { } bool CollisionScript::on_collision(const CollisionEvent & ev) { - RefVector animators = this->get_components_by_name("player"); - RefVector emitters - = this->get_components_by_name("player"); + RefVector animators = this->get_components(); if (ev.info.other.metadata.tag == "zapper") { for (Animator & anim : animators) { @@ -25,9 +20,6 @@ bool CollisionScript::on_collision(const CollisionEvent & ev) { anim.set_anim(4); anim.data.looping = true; } - for (ParticleEmitter & emitter : emitters) { - emitter.data.emission_rate = 0; - } return true; } else if (ev.info.other.metadata.tag == "laser") { @@ -36,11 +28,6 @@ bool CollisionScript::on_collision(const CollisionEvent & ev) { anim.set_anim(4); anim.data.looping = true; } - for (ParticleEmitter & emitter : emitters) { - emitter.data.emission_rate = 0; - } - play_scr.active = false; - end_scr.active = true; return true; } else if (ev.info.other.metadata.tag == "missile") { @@ -49,11 +36,6 @@ bool CollisionScript::on_collision(const CollisionEvent & ev) { anim.set_anim(5); anim.data.looping = true; } - for (ParticleEmitter & emitter : emitters) { - emitter.data.emission_rate = 0; - } - play_scr.active = false; - end_scr.active = true; return true; } -- cgit v1.2.3 From e9082de7d114ce024a884cac38c545c99de4026a Mon Sep 17 00:00:00 2001 From: Max-001 Date: Wed, 8 Jan 2025 09:51:06 +0100 Subject: Finnished collision --- game/CMakeLists.txt | 1 + game/GameScene.cpp | 6 ++--- game/workers/CollisionScript.cpp | 48 +++++++++++++++++++++++++--------- game/workers/PanicFromPlayerScript.cpp | 14 ++++++++-- game/workers/WorkerScript.cpp | 29 ++++++++++++++++++++ game/workers/WorkersSubScene.cpp | 9 +++++++ 6 files changed, 90 insertions(+), 17 deletions(-) (limited to 'game/workers/CollisionScript.cpp') diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 0fb2424..ab770eb 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -25,6 +25,7 @@ add_executable(main workers/WorkersSubScene.cpp workers/WorkerScript.cpp workers/PanicFromPlayerScript.cpp + workers/CollisionScript.cpp main.cpp ) diff --git a/game/GameScene.cpp b/game/GameScene.cpp index 02af8db..97f62e2 100644 --- a/game/GameScene.cpp +++ b/game/GameScene.cpp @@ -80,7 +80,7 @@ void GameScene::load_scene() { boom_audio.add_component(boom_audio_asset); // zapper, laser and missile (below) for testing purpose only!!! - GameObject zapper = new_object("zapper", "zapper", vec2(1000, 0)); + GameObject zapper = new_object("zapper", "zapper", vec2(1000, 200)); Asset zapper_asset {"asset/obstacles/zapper/regular_zappers/zapEffect.png"}; Sprite & zapper_sprite = zapper.add_component( zapper_asset, @@ -96,7 +96,7 @@ void GameScene::load_scene() { .collision_layer = COLL_LAY_ZAPPER, }); zapper.add_component(vec2(100, 100)); - GameObject laser = new_object("laser", "laser", vec2(2000, 0)); + GameObject laser = new_object("laser", "laser", vec2(2000, 200)); Asset laser_asset {"asset/obstacles/laser/laserPower.png"}; Sprite & laser_sprite = laser.add_component( laser_asset, @@ -112,7 +112,7 @@ void GameScene::load_scene() { .collision_layer = COLL_LAY_LASER, }); laser.add_component(vec2(100, 100)); - GameObject missile = new_object("missile", "missile", vec2(4000, 0)); + GameObject missile = new_object("missile", "missile", vec2(4000, 200)); Asset missile_asset {"asset/obstacles/missile/missile.png"}; Sprite & missile_sprite = missile.add_component( missile_asset, diff --git a/game/workers/CollisionScript.cpp b/game/workers/CollisionScript.cpp index baa058b..deaf0ee 100644 --- a/game/workers/CollisionScript.cpp +++ b/game/workers/CollisionScript.cpp @@ -1,6 +1,11 @@ #include "CollisionScript.h" #include +#include +#include +#include +#include +#include using namespace crepe; using namespace std; @@ -13,31 +18,50 @@ void CollisionScript::init() { bool CollisionScript::on_collision(const CollisionEvent & ev) { RefVector animators = this->get_components(); + RefVector sprites = this->get_components(); + Rigidbody & rb = this->get_component(); + Transform & tr = this->get_component(); + BehaviorScript & bs_panic = this->get_components().front(); if (ev.info.other.metadata.tag == "zapper") { for (Animator & anim : animators) { - anim.active = true; - anim.set_anim(4); - anim.data.looping = true; + anim.active = false; + anim.set_anim(3); } + for (Sprite & sprite : sprites) { + sprite.data.position_offset.x = 15; + } + rb.data.linear_velocity_coefficient = {0.5, 0.5}; + tr.rotation = 90; + bs_panic.active = false; - return true; + return false; } else if (ev.info.other.metadata.tag == "laser") { for (Animator & anim : animators) { - anim.active = true; - anim.set_anim(4); - anim.data.looping = true; + anim.active = false; + anim.set_anim(3); + } + for (Sprite & sprite : sprites) { + sprite.data.position_offset.x = 15; } + rb.data.linear_velocity_coefficient = {0.5, 0.5}; + tr.rotation = 90; + bs_panic.active = false; - return true; + return false; } else if (ev.info.other.metadata.tag == "missile") { for (Animator & anim : animators) { - anim.active = true; - anim.set_anim(5); - anim.data.looping = true; + anim.active = false; + anim.set_anim(3); + } + for (Sprite & sprite : sprites) { + sprite.data.position_offset.x = 15; } + rb.data.linear_velocity_coefficient = {0.5, 0.5}; + tr.rotation = 90; + bs_panic.active = false; - return true; + return false; } return false; diff --git a/game/workers/PanicFromPlayerScript.cpp b/game/workers/PanicFromPlayerScript.cpp index 1e49aaa..baa48df 100644 --- a/game/workers/PanicFromPlayerScript.cpp +++ b/game/workers/PanicFromPlayerScript.cpp @@ -32,11 +32,21 @@ void PanicFromPlayerScript::fixed_update(duration_t dt) { } if (result_x < 0) { - rb_worker.data.linear_velocity.x = 10000 * dt.count(); + float min_value = 8000; + float max_value = 10000; + float value = min_value + + static_cast(rand()) + / (static_cast(RAND_MAX / (max_value - min_value))); + rb_worker.data.linear_velocity.x = value * dt.count(); sprite_worker.front().get().data.flip.flip_x = false; sprite_worker.back().get().data.flip.flip_x = false; } else { - rb_worker.data.linear_velocity.x = -5000 * dt.count(); + float min_value = -4000; + float max_value = -5000; + float value = min_value + + static_cast(rand()) + / (static_cast(RAND_MAX / (max_value - min_value))); + rb_worker.data.linear_velocity.x = value * dt.count(); sprite_worker.front().get().data.flip.flip_x = true; sprite_worker.back().get().data.flip.flip_x = true; } diff --git a/game/workers/WorkerScript.cpp b/game/workers/WorkerScript.cpp index 1bcf8d5..b0bfc4e 100644 --- a/game/workers/WorkerScript.cpp +++ b/game/workers/WorkerScript.cpp @@ -1,6 +1,7 @@ #include "WorkerScript.h" #include "../Config.h" +#include "api/BehaviorScript.h" #include #include @@ -44,6 +45,9 @@ void WorkerScript::fixed_update(duration_t dt) { = this->get_components_by_id(trans_worker.game_object_id); RefVector animator_worker = this->get_components_by_id(trans_worker.game_object_id); + BehaviorScript & bs_panic + = this->get_components_by_id(trans_worker.game_object_id) + .front(); if (rb_worker.data.linear_velocity.x < 0) { sprite_worker.front().get().data.flip.flip_x = true; @@ -55,6 +59,8 @@ void WorkerScript::fixed_update(duration_t dt) { = -rb_worker.data.linear_velocity.x / 5; animator_worker.front().get().set_anim(0); animator_worker.back().get().set_anim(0); + animator_worker.front().get().active = true; + animator_worker.back().get().active = true; } else { sprite_worker.front().get().data.flip.flip_x = false; sprite_worker.back().get().data.flip.flip_x = false; @@ -65,6 +71,15 @@ void WorkerScript::fixed_update(duration_t dt) { = rb_worker.data.linear_velocity.x / 5; animator_worker.front().get().set_anim(0); animator_worker.back().get().set_anim(0); + animator_worker.front().get().active = true; + animator_worker.back().get().active = true; + } + + trans_worker.rotation = 0; + bs_panic.active = true; + rb_worker.data.linear_velocity_coefficient = {1, 1}; + for (Sprite & sprite : sprite_worker) { + sprite.data.position_offset.x = 0; } } } else { @@ -84,6 +99,9 @@ void WorkerScript::fixed_update(duration_t dt) { = this->get_components_by_id(trans_worker.game_object_id); RefVector animator_worker = this->get_components_by_id(trans_worker.game_object_id); + BehaviorScript & bs_panic + = this->get_components_by_id(trans_worker.game_object_id) + .front(); if (rb_worker.data.linear_velocity.x < 0) { sprite_worker.front().get().data.flip.flip_x = true; @@ -96,6 +114,8 @@ void WorkerScript::fixed_update(duration_t dt) { animator_worker.front().get().set_anim(0); animator_worker.back().get().set_anim(0); + animator_worker.front().get().active = true; + animator_worker.back().get().active = true; } else { sprite_worker.front().get().data.flip.flip_x = false; sprite_worker.back().get().data.flip.flip_x = false; @@ -107,6 +127,15 @@ void WorkerScript::fixed_update(duration_t dt) { animator_worker.front().get().set_anim(0); animator_worker.back().get().set_anim(0); + animator_worker.front().get().active = true; + animator_worker.back().get().active = true; + } + + trans_worker.rotation = 0; + bs_panic.active = true; + rb_worker.data.linear_velocity_coefficient = {1, 1}; + for (Sprite & sprite : sprite_worker) { + sprite.data.position_offset.x = 0; } } } diff --git a/game/workers/WorkersSubScene.cpp b/game/workers/WorkersSubScene.cpp index 215e3f2..54996d1 100644 --- a/game/workers/WorkersSubScene.cpp +++ b/game/workers/WorkersSubScene.cpp @@ -1,4 +1,5 @@ #include "WorkersSubScene.h" +#include "CollisionScript.h" #include "PanicFromPlayerScript.h" #include "WorkerScript.h" @@ -70,6 +71,7 @@ void WorkersSubScene::worker1(crepe::Scene & scn, float start_x, float init_spee .collision_layers = {COLL_LAY_BOT_TOP}, }); worker_1.add_component().set_script(); + worker_1.add_component().set_script(); if (init_speed < 0) { worker_1_body_sprite.data.flip = Sprite::FlipSettings {true, false}; @@ -118,6 +120,7 @@ void WorkersSubScene::worker2(crepe::Scene & scn, float start_x, float init_spee .collision_layers = {COLL_LAY_BOT_TOP}, }); worker_2.add_component().set_script(); + worker_2.add_component().set_script(); if (init_speed < 0) { worker_2_body_sprite.data.flip = Sprite::FlipSettings {true, false}; @@ -166,6 +169,7 @@ void WorkersSubScene::worker3(crepe::Scene & scn, float start_x, float init_spee .collision_layers = {COLL_LAY_BOT_TOP}, }); worker_3.add_component().set_script(); + worker_3.add_component().set_script(); if (init_speed < 0) { worker_3_body_sprite.data.flip = Sprite::FlipSettings {true, false}; @@ -214,6 +218,7 @@ void WorkersSubScene::worker4(crepe::Scene & scn, float start_x, float init_spee .collision_layers = {COLL_LAY_BOT_HIGH}, }); worker_4.add_component().set_script(); + worker_4.add_component().set_script(); if (init_speed < 0) { worker_4_body_sprite.data.flip = Sprite::FlipSettings {true, false}; @@ -262,6 +267,7 @@ void WorkersSubScene::worker5(crepe::Scene & scn, float start_x, float init_spee .collision_layers = {COLL_LAY_BOT_HIGH}, }); worker_5.add_component().set_script(); + worker_5.add_component().set_script(); if (init_speed < 0) { worker_5_body_sprite.data.flip = Sprite::FlipSettings {true, false}; @@ -310,6 +316,7 @@ void WorkersSubScene::worker6(crepe::Scene & scn, float start_x, float init_spee .collision_layers = {COLL_LAY_BOT_LOW}, }); worker_6.add_component().set_script(); + worker_6.add_component().set_script(); if (init_speed < 0) { worker_6_body_sprite.data.flip = Sprite::FlipSettings {true, false}; @@ -358,6 +365,7 @@ void WorkersSubScene::worker7(crepe::Scene & scn, float start_x, float init_spee .collision_layers = {COLL_LAY_BOT_LOW}, }); worker_7.add_component().set_script(); + worker_7.add_component().set_script(); if (init_speed < 0) { worker_7_body_sprite.data.flip = Sprite::FlipSettings {true, false}; @@ -406,6 +414,7 @@ void WorkersSubScene::worker8(crepe::Scene & scn, float start_x, float init_spee .collision_layers = {COLL_LAY_BOT_LOW}, }); worker_8.add_component().set_script(); + worker_8.add_component().set_script(); if (init_speed < 0) { worker_8_body_sprite.data.flip = Sprite::FlipSettings {true, false}; -- cgit v1.2.3 From 0de6692dcb029540f4502c5a2f1a0c6634f7b61f Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Wed, 8 Jan 2025 14:50:04 +0100 Subject: start of extra features and restored player functions --- game/enemy/EnemyBulletSubScene.cpp | 2 +- game/enemy/EnemyScript.cpp | 10 +++++++++- game/enemy/EnemySubScene.cpp | 9 +++++---- game/player/PlayerBulletSubScene.cpp | 6 +++--- game/player/PlayerSubScene.cpp | 6 +++--- game/workers/CollisionScript.cpp | 2 +- 6 files changed, 22 insertions(+), 13 deletions(-) (limited to 'game/workers/CollisionScript.cpp') diff --git a/game/enemy/EnemyBulletSubScene.cpp b/game/enemy/EnemyBulletSubScene.cpp index edd8f0c..5c31f1d 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}, + .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 6558af5..8e475a8 100644 --- a/game/enemy/EnemyScript.cpp +++ b/game/enemy/EnemyScript.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include using namespace crepe; @@ -82,8 +84,12 @@ bool EnemyScript::spawn_enemy(const SpawnEnemyEvent & e) { bool EnemyScript::on_collide(const CollisionEvent & e) { if (e.info.other.metadata.tag == "player_bullet") { - this->despawn_enemy(); + //this->despawn_enemy(); + } + Animator& body_animator = this->get_components().front(); + body_animator.data.col = 2; + //body_animator.play(); BehaviorScript & enemy_script = this->get_component(); enemy_script.active = false; return false; @@ -110,6 +116,8 @@ 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(); + audio.play(); return; } } diff --git a/game/enemy/EnemySubScene.cpp b/game/enemy/EnemySubScene.cpp index 7d3e784..8316db9 100644 --- a/game/enemy/EnemySubScene.cpp +++ b/game/enemy/EnemySubScene.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "../Config.h" @@ -45,9 +46,8 @@ int EnemySubScene::create(Scene & scn, int enemy_counter) { enemy_body_sprite, ivec2(32, 32), uvec2(4, 8), Animator::Data { .fps = 5, - .col = 3, - .row = 1, - + .col = 1, + .row = 0, .looping = false, } ); @@ -91,7 +91,8 @@ int EnemySubScene::create(Scene & scn, int enemy_counter) { .looping = true, } ); - + 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/player/PlayerBulletSubScene.cpp b/game/player/PlayerBulletSubScene.cpp index 62bcf3e..2d237de 100644 --- a/game/player/PlayerBulletSubScene.cpp +++ b/game/player/PlayerBulletSubScene.cpp @@ -24,10 +24,10 @@ int PlayerBulletSubScene::create(Scene & scn, int counter) { Rigidbody & player_bullet_body = player_bullet.add_component(Rigidbody::Data { .gravity_scale = 0, .body_type = Rigidbody::BodyType::KINEMATIC, - .linear_velocity = vec2 {300, 0}, - .angular_velocity = 150, + .linear_velocity = vec2 {400, 0}, + .angular_velocity = 10, .kinematic_collision = false, - .collision_layers = {COLL_LAY_ENEMY}, + .collision_layers = {COLL_LAY_ENEMY,COLL_LAY_ZAPPER}, .collision_layer = COLL_LAY_PLAYER_BULLET, diff --git a/game/player/PlayerSubScene.cpp b/game/player/PlayerSubScene.cpp index cf11162..c4d689a 100644 --- a/game/player/PlayerSubScene.cpp +++ b/game/player/PlayerSubScene.cpp @@ -22,7 +22,7 @@ using namespace crepe; using namespace std; PlayerSubScene::PlayerSubScene(Scene & scn) { - GameObject player = scn.new_object("player", "player", vec2(300, 200)); + GameObject player = scn.new_object("player", "player", vec2(-100, 200)); Asset player_bullet {"asset/other_effects/effect_smgbullet.png"}; Sprite & player_bullet_sprite = player.add_component( @@ -147,13 +147,13 @@ PlayerSubScene::PlayerSubScene(Scene & scn) { player.add_component(Rigidbody::Data { .gravity_scale = PLAYER_GRAVITY_SCALE, .body_type = Rigidbody::BodyType::DYNAMIC, - //.linear_velocity = vec2(PLAYER_SPEED * 0.02, 0), + .linear_velocity = vec2(PLAYER_SPEED * 0.02, 0), .collision_layers = {COLL_LAY_BOT_TOP, COLL_LAY_ZAPPER, COLL_LAY_LASER, COLL_LAY_MISSILE, COLL_LAY_BULLET }, .collision_layer = COLL_LAY_PLAYER, }); - player.add_component().set_script().active = true; + player.add_component().set_script().active = false; player.add_component().set_script(); player.add_component().set_script().active = false; diff --git a/game/workers/CollisionScript.cpp b/game/workers/CollisionScript.cpp index deaf0ee..625044d 100644 --- a/game/workers/CollisionScript.cpp +++ b/game/workers/CollisionScript.cpp @@ -49,7 +49,7 @@ bool CollisionScript::on_collision(const CollisionEvent & ev) { bs_panic.active = false; return false; - } else if (ev.info.other.metadata.tag == "missile") { + } 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 From bb976ed881a989b8b2cec90c905d906d9b652a9d Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 8 Jan 2025 16:20:10 +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.cpp | 12 +++++++----- game/scheduler/ObjectsScheduler.h | 6 +----- game/workers/CollisionScript.cpp | 3 ++- 9 files changed, 18 insertions(+), 22 deletions(-) (limited to 'game/workers/CollisionScript.cpp') 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.cpp b/game/scheduler/ObjectsScheduler.cpp index 02d84c1..fca8fa2 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" @@ -16,15 +16,17 @@ void ObjectsScheduler::preset_1() { trigger_event(MissileSpaw void ObjectsScheduler::preset_2() { trigger_event(CreateZapperEvent {}); } void ObjectsScheduler::preset_3() {} 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; } 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