From a7bb9c455f8ebd197d1651d85efebd18f5ac971f Mon Sep 17 00:00:00 2001 From: Max-001 Date: Tue, 7 Jan 2025 15:10:25 +0100 Subject: Added the whole background --- game/background/BackgroundSubScene.cpp | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/game/background/BackgroundSubScene.cpp b/game/background/BackgroundSubScene.cpp index 6fdc598..a7ac916 100644 --- a/game/background/BackgroundSubScene.cpp +++ b/game/background/BackgroundSubScene.cpp @@ -34,4 +34,50 @@ BackgroundSubScene::BackgroundSubScene(Scene & scn) { begin_x = hallway.create(scn, begin_x, 4, Color::GREEN); begin_x = aquarium.create(scn, begin_x); + + begin_x = hallway.create(scn, begin_x, 5, Color::RED); + + begin_x = forest.create(scn, begin_x, "3"); + + begin_x = hallway.create(scn, begin_x, 6, Color::BLUE); + + begin_x = aquarium.create(scn, begin_x); + + begin_x = hallway.create(scn, begin_x, 7, Color::WHITE); + + begin_x = forest.create(scn, begin_x, "4"); + + begin_x = hallway.create(scn, begin_x, 8, Color::YELLOW); + + begin_x = aquarium.create(scn, begin_x); + + begin_x = hallway.create(scn, begin_x, 9, Color::MAGENTA); + + begin_x = forest.create(scn, begin_x, "5"); + + begin_x = hallway.create(scn, begin_x, 10, Color::CYAN); + + begin_x = aquarium.create(scn, begin_x); + + begin_x = hallway.create(scn, begin_x, 11, Color::GREEN); + + begin_x = forest.create(scn, begin_x, "6"); + + begin_x = hallway.create(scn, begin_x, 12, Color::RED); + + begin_x = aquarium.create(scn, begin_x); + + begin_x = hallway.create(scn, begin_x, 13, Color::BLUE); + + begin_x = forest.create(scn, begin_x, "7"); + + begin_x = hallway.create(scn, begin_x, 14, Color::WHITE); + + begin_x = aquarium.create(scn, begin_x); + + begin_x = hallway.create(scn, begin_x, 15, Color::YELLOW); + + begin_x = forest.create(scn, begin_x, "8"); + + begin_x = hallway.create(scn, begin_x, 16, Color::MAGENTA); } -- cgit v1.2.3 From 1a4dcd898138e6f1de5a8fbb6f0388f39b338189 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Tue, 7 Jan 2025 16:22:18 +0100 Subject: Added extra sorting layer for workers --- game/Config.h | 3 ++- game/workers/WorkersSubScene.cpp | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/game/Config.h b/game/Config.h index ea95a90..d5208d8 100644 --- a/game/Config.h +++ b/game/Config.h @@ -5,8 +5,9 @@ static constexpr int SORT_IN_LAY_BACKGROUND = 4; // For all scenes static constexpr int SORT_IN_LAY_FORE_BACKGROUND = 5; // For all scenes static constexpr int SORT_IN_LAY_PARTICLES_BACKGROUND = 6; // For all scenes static constexpr int SORT_IN_LAY_OBSTACLES = 8; // Only for GameScene +static constexpr int SORT_IN_LAY_WORKERS_BACK = 9; // Only for GameScene static constexpr int SORT_IN_LAY_PLAYER = 10; // Only for GameScene -static constexpr int SORT_IN_LAY_WORKERS = 12; // Only for GameScene +static constexpr int SORT_IN_LAY_WORKERS_FRONT = 12; // Only for GameScene static constexpr int SORT_IN_LAY_PARTICLES_FOREGROUND = 15; // Only for GameScene static constexpr int COLL_LAY_BOT_TOP = 1; // Only for GameScene diff --git a/game/workers/WorkersSubScene.cpp b/game/workers/WorkersSubScene.cpp index e5b4678..215e3f2 100644 --- a/game/workers/WorkersSubScene.cpp +++ b/game/workers/WorkersSubScene.cpp @@ -34,7 +34,7 @@ void WorkersSubScene::worker1(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_1_body_sprite = worker_1.add_component( Asset {"asset/workers/worker1Body.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_BACK, .order_in_layer = 0, .size = vec2(0, 50), } @@ -49,7 +49,7 @@ void WorkersSubScene::worker1(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_1_head_sprite = worker_1.add_component( Asset {"asset/workers/worker1Head.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_BACK, .order_in_layer = 1, .size = vec2(0, 50), .position_offset = vec2(0, -20), @@ -82,7 +82,7 @@ void WorkersSubScene::worker2(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_2_body_sprite = worker_2.add_component( Asset {"asset/workers/worker2Body.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_FRONT, .order_in_layer = 2, .size = vec2(0, 50), } @@ -97,7 +97,7 @@ void WorkersSubScene::worker2(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_2_head_sprite = worker_2.add_component( Asset {"asset/workers/worker1Head.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_FRONT, .order_in_layer = 3, .size = vec2(0, 50), .position_offset = vec2(0, -20), @@ -130,7 +130,7 @@ void WorkersSubScene::worker3(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_3_body_sprite = worker_3.add_component( Asset {"asset/workers/worker1Body.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_BACK, .order_in_layer = 4, .size = vec2(0, 50), } @@ -145,7 +145,7 @@ void WorkersSubScene::worker3(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_3_head_sprite = worker_3.add_component( Asset {"asset/workers/worker2Head.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_BACK, .order_in_layer = 5, .size = vec2(0, 50), .position_offset = vec2(0, -20), @@ -178,7 +178,7 @@ void WorkersSubScene::worker4(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_4_body_sprite = worker_4.add_component( Asset {"asset/workers/worker2Body.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_FRONT, .order_in_layer = 6, .size = vec2(0, 50), } @@ -193,7 +193,7 @@ void WorkersSubScene::worker4(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_4_head_sprite = worker_4.add_component( Asset {"asset/workers/worker2Head.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_FRONT, .order_in_layer = 7, .size = vec2(0, 50), .position_offset = vec2(0, -20), @@ -226,7 +226,7 @@ void WorkersSubScene::worker5(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_5_body_sprite = worker_5.add_component( Asset {"asset/workers/workerFatBody.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_BACK, .order_in_layer = 8, .size = vec2(0, 50), } @@ -241,7 +241,7 @@ void WorkersSubScene::worker5(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_5_head_sprite = worker_5.add_component( Asset {"asset/workers/worker1Head.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_BACK, .order_in_layer = 9, .size = vec2(0, 50), .position_offset = vec2(0, -20), @@ -274,7 +274,7 @@ void WorkersSubScene::worker6(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_6_body_sprite = worker_6.add_component( Asset {"asset/workers/workerFatBody.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_FRONT, .order_in_layer = 10, .size = vec2(0, 50), } @@ -289,7 +289,7 @@ void WorkersSubScene::worker6(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_6_head_sprite = worker_6.add_component( Asset {"asset/workers/worker2Head.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_FRONT, .order_in_layer = 11, .size = vec2(0, 50), .position_offset = vec2(0, -20), @@ -322,7 +322,7 @@ void WorkersSubScene::worker7(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_7_body_sprite = worker_7.add_component( Asset {"asset/workers/workerTallBody.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_BACK, .order_in_layer = 12, .size = vec2(0, 50), } @@ -337,7 +337,7 @@ void WorkersSubScene::worker7(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_7_head_sprite = worker_7.add_component( Asset {"asset/workers/worker1Head.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_BACK, .order_in_layer = 13, .size = vec2(0, 50), .position_offset = vec2(0, -20), @@ -370,7 +370,7 @@ void WorkersSubScene::worker8(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_8_body_sprite = worker_8.add_component( Asset {"asset/workers/workerTallBody.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_FRONT, .order_in_layer = 14, .size = vec2(0, 50), } @@ -385,7 +385,7 @@ void WorkersSubScene::worker8(crepe::Scene & scn, float start_x, float init_spee Sprite & worker_8_head_sprite = worker_8.add_component( Asset {"asset/workers/worker2Head.png"}, Sprite::Data { - .sorting_in_layer = SORT_IN_LAY_WORKERS, + .sorting_in_layer = SORT_IN_LAY_WORKERS_FRONT, .order_in_layer = 15, .size = vec2(0, 50), .position_offset = vec2(0, -20), -- cgit v1.2.3 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 ++++++++++++++++++++++++++++++++++++++++ game/workers/CollisionScript.h | 12 ++++++++ 2 files changed, 74 insertions(+) create mode 100644 game/workers/CollisionScript.cpp create mode 100644 game/workers/CollisionScript.h 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; +} diff --git a/game/workers/CollisionScript.h b/game/workers/CollisionScript.h new file mode 100644 index 0000000..70c5fe1 --- /dev/null +++ b/game/workers/CollisionScript.h @@ -0,0 +1,12 @@ +#pragma once + +#include +#include + +class CollisionScript : public crepe::Script { +public: + void init(); + +private: + bool on_collision(const crepe::CollisionEvent & ev); +}; -- 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(-) 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(-) 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 1c00c12c8a2c1e896b97479601242b71503f7c30 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Wed, 8 Jan 2025 10:14:45 +0100 Subject: Commented out 3/4 of level --- game/background/BackgroundSubScene.cpp | 4 ++-- game/menus/ButtonSetMainMenuSubScript.h | 1 + game/menus/ButtonSetShopSubScript.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/game/background/BackgroundSubScene.cpp b/game/background/BackgroundSubScene.cpp index a7ac916..0f54800 100644 --- a/game/background/BackgroundSubScene.cpp +++ b/game/background/BackgroundSubScene.cpp @@ -33,7 +33,7 @@ BackgroundSubScene::BackgroundSubScene(Scene & scn) { begin_x = hallway.create(scn, begin_x, 4, Color::GREEN); - begin_x = aquarium.create(scn, begin_x); + /*begin_x = aquarium.create(scn, begin_x); begin_x = hallway.create(scn, begin_x, 5, Color::RED); @@ -79,5 +79,5 @@ BackgroundSubScene::BackgroundSubScene(Scene & scn) { begin_x = forest.create(scn, begin_x, "8"); - begin_x = hallway.create(scn, begin_x, 16, Color::MAGENTA); + begin_x = hallway.create(scn, begin_x, 16, Color::MAGENTA);*/ } diff --git a/game/menus/ButtonSetMainMenuSubScript.h b/game/menus/ButtonSetMainMenuSubScript.h index 0feefdd..2fb2634 100644 --- a/game/menus/ButtonSetMainMenuSubScript.h +++ b/game/menus/ButtonSetMainMenuSubScript.h @@ -8,6 +8,7 @@ class ButtonSetMainMenuSubScript : public IButtonScript { public: void init() override; bool on_button_press(const crepe::ButtonPressEvent & e); + protected: bool transition = false; }; diff --git a/game/menus/ButtonSetShopSubScript.h b/game/menus/ButtonSetShopSubScript.h index 64d0bf5..4017a4c 100644 --- a/game/menus/ButtonSetShopSubScript.h +++ b/game/menus/ButtonSetShopSubScript.h @@ -8,6 +8,7 @@ class ButtonSetShopSubScript : public IButtonScript { public: void init() override; bool on_button_press(const crepe::ButtonPressEvent & e); + protected: bool transition = false; }; -- cgit v1.2.3 From b2fb4028f13f47d89487d48a1cc1e3e062d81e35 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Wed, 8 Jan 2025 11:08:30 +0100 Subject: Made background move to next position --- game/CMakeLists.txt | 1 + game/background/BackgroundSubScene.cpp | 14 +++++-- game/background/HallwayScript.cpp | 70 ++++++++++++++++++++++++++++++++++ game/background/HallwayScript.h | 13 +++++++ game/background/HallwaySubScene.cpp | 16 +++++--- 5 files changed, 105 insertions(+), 9 deletions(-) create mode 100644 game/background/HallwayScript.cpp create mode 100644 game/background/HallwayScript.h diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 475d6e1..a0e09de 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -15,6 +15,7 @@ add_executable(main background/ForestSubScene.cpp GameScene.cpp background/HallwaySubScene.cpp + background/HallwayScript.cpp MoveCameraManualyScript.cpp player/PlayerScript.cpp player/PlayerSubScene.cpp diff --git a/game/background/BackgroundSubScene.cpp b/game/background/BackgroundSubScene.cpp index 0f54800..a954f0b 100644 --- a/game/background/BackgroundSubScene.cpp +++ b/game/background/BackgroundSubScene.cpp @@ -1,10 +1,13 @@ #include "BackgroundSubScene.h" #include "AquariumSubScene.h" #include "ForestSubScene.h" +#include "HallwayScript.h" #include "HallwaySubScene.h" #include "StartSubScene.h" +#include #include +#include using namespace crepe; using namespace std; @@ -23,15 +26,17 @@ BackgroundSubScene::BackgroundSubScene(Scene & scn) { begin_x = forest.create(scn, begin_x, "1"); - begin_x = hallway.create(scn, begin_x, 2, Color::MAGENTA); + begin_x += 3000; + //begin_x = hallway.create(scn, begin_x, 2, Color::MAGENTA); begin_x = aquarium.create(scn, begin_x); - begin_x = hallway.create(scn, begin_x, 3, Color::CYAN); + begin_x += 3000; + //begin_x = hallway.create(scn, begin_x, 3, Color::CYAN); begin_x = forest.create(scn, begin_x, "2"); - begin_x = hallway.create(scn, begin_x, 4, Color::GREEN); + //begin_x = hallway.create(scn, begin_x, 4, Color::GREEN); /*begin_x = aquarium.create(scn, begin_x); @@ -80,4 +85,7 @@ BackgroundSubScene::BackgroundSubScene(Scene & scn) { begin_x = forest.create(scn, begin_x, "8"); begin_x = hallway.create(scn, begin_x, 16, Color::MAGENTA);*/ + + GameObject scripts = scn.new_object("scrips_background", "background"); + scripts.add_component().set_script(); } diff --git a/game/background/HallwayScript.cpp b/game/background/HallwayScript.cpp new file mode 100644 index 0000000..a5bb94c --- /dev/null +++ b/game/background/HallwayScript.cpp @@ -0,0 +1,70 @@ +#include "HallwayScript.h" + +#include "../Config.h" + +#include +#include +#include +#include + +using namespace crepe; +using namespace std; + +void HallwayScript::fixed_update(crepe::duration_t dt) { + Transform & trans_cam = this->get_components_by_name("camera").front(); + + float cam_left_x = trans_cam.position.x - VIEWPORT_X / 2; + + if (cam_left_x > this->start_x + this->lenght) { + //Move whole background 6000 to the right + RefVector trans = this->get_components_by_tag("background_hall"); + for (Transform & tran : trans) { + tran.position.x += 6000; + } + this->start_x += 6000; + + //Change sector number + Animator & anim = this->get_components_by_name("hallway_begin").front(); + int column = (current_sector - 1) / 4; + int row = (current_sector - 1) % 4; + anim.set_anim(column); + for (int i = 0; i < row; i++) { + anim.next_anim(); + } + RefVector sprites = this->get_components_by_name("hallway_begin"); + switch (current_sector % 7) { + case 0: + sprites[1].get().data.color = Color::YELLOW; + sprites[2].get().data.color = Color::YELLOW; + break; + case 1: + sprites[1].get().data.color = Color::MAGENTA; + sprites[2].get().data.color = Color::MAGENTA; + break; + case 2: + sprites[1].get().data.color = Color::CYAN; + sprites[2].get().data.color = Color::CYAN; + break; + case 3: + sprites[1].get().data.color = Color::GREEN; + sprites[2].get().data.color = Color::GREEN; + break; + case 4: + sprites[1].get().data.color = Color::RED; + sprites[2].get().data.color = Color::RED; + break; + case 5: + sprites[1].get().data.color = Color::BLUE; + sprites[2].get().data.color = Color::BLUE; + break; + case 6: + sprites[1].get().data.color = Color::WHITE; + sprites[2].get().data.color = Color::WHITE; + break; + } + current_sector++; + if (current_sector > 16) { + current_sector = 1; + } + } +} diff --git a/game/background/HallwayScript.h b/game/background/HallwayScript.h new file mode 100644 index 0000000..04b2933 --- /dev/null +++ b/game/background/HallwayScript.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +class HallwayScript : public crepe::Script { +public: + void fixed_update(crepe::duration_t dt); + +private: + float start_x = 1200; + const float lenght = 3000; + int current_sector = 2; +}; diff --git a/game/background/HallwaySubScene.cpp b/game/background/HallwaySubScene.cpp index 4d96c94..31af2d5 100644 --- a/game/background/HallwaySubScene.cpp +++ b/game/background/HallwaySubScene.cpp @@ -14,7 +14,7 @@ using namespace std; float HallwaySubScene::create( Scene & scn, float begin_x, unsigned int sector_num, Color sector_color ) { - GameObject begin = scn.new_object("hallway_begin", "background", vec2(begin_x, 0)); + GameObject begin = scn.new_object("hallway_begin", "background_hall", vec2(begin_x, 0)); Asset begin_asset {"asset/background/hallway/hallway1FG_1_TVOS.png"}; begin.add_component( begin_asset, @@ -30,7 +30,8 @@ float HallwaySubScene::create( this->add_lamp(begin, vec2(330, -120), 11); this->add_lamp(begin, vec2(430, -120), 9); - GameObject middle_1 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); + GameObject middle_1 + = scn.new_object("hallway_middle", "background_hall", vec2(begin_x, 0)); Asset middle_asset {"asset/background/hallway/hallway1FG_2_TVOS.png"}; middle_1.add_component( middle_asset, @@ -42,7 +43,8 @@ float HallwaySubScene::create( ); begin_x += 600; - GameObject middle_2 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); + GameObject middle_2 + = scn.new_object("hallway_middle", "background_hall", vec2(begin_x, 0)); Asset middle_asset_2 {"asset/background/hallway/hallway1FG_2_TVOS.png"}; middle_2.add_component( middle_asset_2, @@ -54,7 +56,8 @@ float HallwaySubScene::create( ); begin_x += 200; - GameObject middle_3 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); + GameObject middle_3 + = scn.new_object("hallway_middle", "background_hall", vec2(begin_x, 0)); Asset middle_asset_3 {"asset/background/hallway/hallway1FG_2_TVOS.png"}; middle_3.add_component( middle_asset_3, @@ -68,7 +71,8 @@ float HallwaySubScene::create( this->add_lamp(middle_3, vec2(0, -120)); - GameObject middle_4 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); + GameObject middle_4 + = scn.new_object("hallway_middle", "background_hall", vec2(begin_x, 0)); Asset middle_asset_4 {"asset/background/hallway/hallway1FG_2_TVOS.png"}; middle_4.add_component( middle_asset_4, @@ -80,7 +84,7 @@ float HallwaySubScene::create( ); begin_x += 600; - GameObject end = scn.new_object("hallway_end", "background", vec2(begin_x, 0)); + GameObject end = scn.new_object("hallway_end", "background_hall", vec2(begin_x, 0)); Asset end_asset {"asset/background/hallway/hallway1FG_1_TVOS.png"}; end.add_component( end_asset, -- cgit v1.2.3 From 8fc12804f7f0203564cd6352cf47da13a4f46641 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Wed, 8 Jan 2025 11:22:53 +0100 Subject: Made background aquarium move --- game/CMakeLists.txt | 1 + game/background/AquariumScript.cpp | 26 ++++++++++++++++++++++++++ game/background/AquariumScript.h | 12 ++++++++++++ game/background/AquariumSubScene.cpp | 19 ++++++++++--------- game/background/BackgroundSubScene.cpp | 6 ++++-- 5 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 game/background/AquariumScript.cpp create mode 100644 game/background/AquariumScript.h diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index a0e09de..662a5e7 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -10,6 +10,7 @@ project(game C CXX) add_subdirectory(../src crepe) add_executable(main background/AquariumSubScene.cpp + background/AquariumScript.cpp background/BackgroundSubScene.cpp background/ForestParallaxScript.cpp background/ForestSubScene.cpp diff --git a/game/background/AquariumScript.cpp b/game/background/AquariumScript.cpp new file mode 100644 index 0000000..e698e3a --- /dev/null +++ b/game/background/AquariumScript.cpp @@ -0,0 +1,26 @@ +#include "AquariumScript.h" + +#include "../Config.h" + +#include +#include +#include +#include + +using namespace crepe; +using namespace std; + +void AquariumScript::fixed_update(crepe::duration_t dt) { + Transform & trans_cam = this->get_components_by_name("camera").front(); + + float cam_left_x = trans_cam.position.x - VIEWPORT_X / 2; + + if (cam_left_x > this->start_x + this->lenght) { + //Move whole background 12000 to the right + RefVector trans = this->get_components_by_tag("background_aqua"); + for (Transform & tran : trans) { + tran.position.x += 12000; + } + this->start_x += 12000; + } +} diff --git a/game/background/AquariumScript.h b/game/background/AquariumScript.h new file mode 100644 index 0000000..b068628 --- /dev/null +++ b/game/background/AquariumScript.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +class AquariumScript : public crepe::Script { +public: + void fixed_update(crepe::duration_t dt); + +private: + float start_x = 10200; + const float lenght = 3000; +}; diff --git a/game/background/AquariumSubScene.cpp b/game/background/AquariumSubScene.cpp index 8d5202a..99466e3 100644 --- a/game/background/AquariumSubScene.cpp +++ b/game/background/AquariumSubScene.cpp @@ -15,7 +15,7 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { this->add_background(scn, begin_x); GameObject aquarium_begin - = scn.new_object("aquarium_begin", "background", vec2(begin_x, 0)); + = scn.new_object("aquarium_begin", "background_aqua", vec2(begin_x, 0)); Asset aquarium_begin_asset {"asset/background/aquarium/glassTubeFG_1_TVOS.png"}; aquarium_begin.add_component( aquarium_begin_asset, @@ -28,7 +28,7 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { begin_x += 600; GameObject aquarium_middle_1 - = scn.new_object("aquarium_middle", "background", vec2(begin_x, 0)); + = scn.new_object("aquarium_middle", "background_aqua", vec2(begin_x, 0)); Asset aquarium_middle_1_asset {"asset/background/aquarium/glassTubeFG_3_TVOS.png"}; aquarium_middle_1.add_component( aquarium_middle_1_asset, @@ -43,7 +43,7 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { this->add_background(scn, begin_x - 200); GameObject aquarium_middle_2 - = scn.new_object("aquarium_middle", "background", vec2(begin_x, 0)); + = scn.new_object("aquarium_middle", "background_aqua", vec2(begin_x, 0)); Asset aquarium_middle_2_asset {"asset/background/aquarium/glassTubeFG_3_TVOS.png"}; aquarium_middle_2.add_component( aquarium_middle_2_asset, @@ -56,7 +56,7 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { begin_x += 400; GameObject aquarium_middle_3 - = scn.new_object("aquarium_middle", "background", vec2(begin_x, 0)); + = scn.new_object("aquarium_middle", "background_aqua", vec2(begin_x, 0)); Asset aquarium_middle_3_asset {"asset/background/aquarium/glassTubeFG_3_TVOS.png"}; aquarium_middle_3.add_component( aquarium_middle_3_asset, @@ -71,7 +71,7 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { this->add_background(scn, begin_x - 200); GameObject aquarium_middle_4 - = scn.new_object("aquarium_middle", "background", vec2(begin_x, 0)); + = scn.new_object("aquarium_middle", "background_aqua", vec2(begin_x, 0)); Asset aquarium_middle_4_asset {"asset/background/aquarium/glassTubeFG_3_TVOS.png"}; aquarium_middle_4.add_component( aquarium_middle_4_asset, @@ -85,7 +85,8 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { this->add_background(scn, begin_x); - GameObject aquarium_end = scn.new_object("aquarium_end", "background", vec2(begin_x, 0)); + GameObject aquarium_end + = scn.new_object("aquarium_end", "background_aqua", vec2(begin_x, 0)); Asset aquarium_end_asset {"asset/background/aquarium/glassTubeFG_2_TVOS.png"}; aquarium_end.add_component( aquarium_end_asset, @@ -101,7 +102,7 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { } void AquariumSubScene::add_background(Scene & scn, float begin_x) { - GameObject bg_1 = scn.new_object("aquarium_bg_1", "aquarium_background", vec2(begin_x, 0)); + GameObject bg_1 = scn.new_object("aquarium_bg_1", "background_aqua", vec2(begin_x, 0)); Asset bg_1_1_asset {"asset/background/aquarium/AquariumBG1_1_TVOS.png"}; bg_1.add_component( bg_1_1_asset, @@ -122,7 +123,7 @@ void AquariumSubScene::add_background(Scene & scn, float begin_x) { .position_offset = vec2(200, 100), } ); - GameObject bg_2 = scn.new_object("aquarium_bg_2", "aquarium_background", vec2(begin_x, 0)); + GameObject bg_2 = scn.new_object("aquarium_bg_2", "background_aqua", vec2(begin_x, 0)); Asset bg_2_1_asset {"asset/background/aquarium/AquariumBG2_1_TVOS.png"}; bg_2.add_component( bg_2_1_asset, @@ -143,7 +144,7 @@ void AquariumSubScene::add_background(Scene & scn, float begin_x) { .position_offset = vec2(-200, -50), } ); - GameObject bg_3 = scn.new_object("aquarium_bg_3", "aquarium_background", vec2(begin_x, 0)); + GameObject bg_3 = scn.new_object("aquarium_bg_3", "background_aqua", vec2(begin_x, 0)); Asset bg_3_1_asset {"asset/background/aquarium/AquariumBG3_1_TVOS.png"}; bg_3.add_component( bg_3_1_asset, diff --git a/game/background/BackgroundSubScene.cpp b/game/background/BackgroundSubScene.cpp index a954f0b..14258be 100644 --- a/game/background/BackgroundSubScene.cpp +++ b/game/background/BackgroundSubScene.cpp @@ -1,4 +1,5 @@ #include "BackgroundSubScene.h" +#include "AquariumScript.h" #include "AquariumSubScene.h" #include "ForestSubScene.h" #include "HallwayScript.h" @@ -31,10 +32,10 @@ BackgroundSubScene::BackgroundSubScene(Scene & scn) { begin_x = aquarium.create(scn, begin_x); - begin_x += 3000; + //begin_x += 3000; //begin_x = hallway.create(scn, begin_x, 3, Color::CYAN); - begin_x = forest.create(scn, begin_x, "2"); + //begin_x = forest.create(scn, begin_x, "2"); //begin_x = hallway.create(scn, begin_x, 4, Color::GREEN); @@ -88,4 +89,5 @@ BackgroundSubScene::BackgroundSubScene(Scene & scn) { GameObject scripts = scn.new_object("scrips_background", "background"); scripts.add_component().set_script(); + scripts.add_component().set_script(); } -- cgit v1.2.3 From d9bde56d64ec9154d99425015ca1f9d5ce1ebb0f Mon Sep 17 00:00:00 2001 From: Max-001 Date: Wed, 8 Jan 2025 11:51:22 +0100 Subject: Made background forest --- game/background/ForestParallaxScript.cpp | 26 ++++++++++++++++++++++++++ game/background/ForestParallaxScript.h | 6 ++++-- game/background/ForestSubScene.cpp | 12 +++++++----- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/game/background/ForestParallaxScript.cpp b/game/background/ForestParallaxScript.cpp index c72f85d..7470da2 100644 --- a/game/background/ForestParallaxScript.cpp +++ b/game/background/ForestParallaxScript.cpp @@ -1,5 +1,7 @@ #include "ForestParallaxScript.h" +#include "../Config.h" + using namespace crepe; using namespace std; @@ -26,4 +28,28 @@ void ForestParallaxScript::fixed_update(crepe::duration_t dt) { t.position.x = begin_x - 400; } } + + //Move whole background 12000 to the right + Transform & trans_cam = this->get_components_by_name("camera").front(); + + float cam_left_x = trans_cam.position.x - VIEWPORT_X / 2; + + if (cam_left_x > this->start_x + this->lenght) { + //Move whole background 12000 to the right + RefVector trans + = this->get_components_by_tag("background_forest"); + for (Transform & tran : trans) { + tran.position.x += 12000; + } + this->start_x += 12000; + + RefVector trans_back + = this->get_components_by_tag("forest_background"); + for (Transform & tran : trans_back) { + tran.position.x += 12000; + } + + begin_x += 12000; + end_x += 12000; + } } diff --git a/game/background/ForestParallaxScript.h b/game/background/ForestParallaxScript.h index a65a684..d45fdd9 100644 --- a/game/background/ForestParallaxScript.h +++ b/game/background/ForestParallaxScript.h @@ -9,7 +9,9 @@ public: void fixed_update(crepe::duration_t dt); private: - const float begin_x; - const float end_x; + float begin_x; + float end_x; const std::string name; + float start_x = 4200; + const float lenght = 3000; }; diff --git a/game/background/ForestSubScene.cpp b/game/background/ForestSubScene.cpp index a807a36..83e48dd 100644 --- a/game/background/ForestSubScene.cpp +++ b/game/background/ForestSubScene.cpp @@ -15,14 +15,14 @@ using namespace crepe; using namespace std; float ForestSubScene::create(Scene & scn, float begin_x, std::string unique_bg_name) { - GameObject script = scn.new_object("forest_script", "background"); + GameObject script = scn.new_object("forest_script", "background_forest"); script.add_component().set_script( begin_x - 400, begin_x + 3000 + 400, unique_bg_name ); this->add_background(scn, begin_x, unique_bg_name); - GameObject begin = scn.new_object("forest_begin", "background", vec2(begin_x, 0)); + GameObject begin = scn.new_object("forest_begin", "background_forest", vec2(begin_x, 0)); Asset begin_asset {"asset/background/forest/forestFG_1_TVOS.png"}; begin.add_component( begin_asset, @@ -36,7 +36,8 @@ float ForestSubScene::create(Scene & scn, float begin_x, std::string unique_bg_n this->add_background(scn, begin_x, unique_bg_name); - GameObject middle_1 = scn.new_object("forest_middle", "background", vec2(begin_x, 0)); + GameObject middle_1 + = scn.new_object("forest_middle", "background_forest", vec2(begin_x, 0)); Asset middle_1_asset {"asset/background/forest/forestFG_3_TVOS.png"}; middle_1.add_component( middle_1_asset, @@ -50,7 +51,8 @@ float ForestSubScene::create(Scene & scn, float begin_x, std::string unique_bg_n this->add_background(scn, begin_x, unique_bg_name); - GameObject middle_2 = scn.new_object("forest_middle", "background", vec2(begin_x, 0)); + GameObject middle_2 + = scn.new_object("forest_middle", "background_forest", vec2(begin_x, 0)); Asset middle_2_asset {"asset/background/forest/forestFG_3_TVOS.png"}; middle_2.add_component( middle_2_asset, @@ -64,7 +66,7 @@ float ForestSubScene::create(Scene & scn, float begin_x, std::string unique_bg_n this->add_background(scn, begin_x, unique_bg_name); - GameObject end = scn.new_object("forest_end", "background", vec2(begin_x, 0)); + GameObject end = scn.new_object("forest_end", "background_forest", vec2(begin_x, 0)); Asset end_asset {"asset/background/forest/forestFG_2_TVOS.png"}; end.add_component( end_asset, -- cgit v1.2.3 From b1e2df1e75e7fc8ea4c30b7deaa54a7acf02d951 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Wed, 8 Jan 2025 11:58:25 +0100 Subject: Fixes --- game/background/BackgroundSubScene.cpp | 56 ---------------------------------- 1 file changed, 56 deletions(-) diff --git a/game/background/BackgroundSubScene.cpp b/game/background/BackgroundSubScene.cpp index 14258be..4bbd977 100644 --- a/game/background/BackgroundSubScene.cpp +++ b/game/background/BackgroundSubScene.cpp @@ -28,65 +28,9 @@ BackgroundSubScene::BackgroundSubScene(Scene & scn) { begin_x = forest.create(scn, begin_x, "1"); begin_x += 3000; - //begin_x = hallway.create(scn, begin_x, 2, Color::MAGENTA); begin_x = aquarium.create(scn, begin_x); - //begin_x += 3000; - //begin_x = hallway.create(scn, begin_x, 3, Color::CYAN); - - //begin_x = forest.create(scn, begin_x, "2"); - - //begin_x = hallway.create(scn, begin_x, 4, Color::GREEN); - - /*begin_x = aquarium.create(scn, begin_x); - - begin_x = hallway.create(scn, begin_x, 5, Color::RED); - - begin_x = forest.create(scn, begin_x, "3"); - - begin_x = hallway.create(scn, begin_x, 6, Color::BLUE); - - begin_x = aquarium.create(scn, begin_x); - - begin_x = hallway.create(scn, begin_x, 7, Color::WHITE); - - begin_x = forest.create(scn, begin_x, "4"); - - begin_x = hallway.create(scn, begin_x, 8, Color::YELLOW); - - begin_x = aquarium.create(scn, begin_x); - - begin_x = hallway.create(scn, begin_x, 9, Color::MAGENTA); - - begin_x = forest.create(scn, begin_x, "5"); - - begin_x = hallway.create(scn, begin_x, 10, Color::CYAN); - - begin_x = aquarium.create(scn, begin_x); - - begin_x = hallway.create(scn, begin_x, 11, Color::GREEN); - - begin_x = forest.create(scn, begin_x, "6"); - - begin_x = hallway.create(scn, begin_x, 12, Color::RED); - - begin_x = aquarium.create(scn, begin_x); - - begin_x = hallway.create(scn, begin_x, 13, Color::BLUE); - - begin_x = forest.create(scn, begin_x, "7"); - - begin_x = hallway.create(scn, begin_x, 14, Color::WHITE); - - begin_x = aquarium.create(scn, begin_x); - - begin_x = hallway.create(scn, begin_x, 15, Color::YELLOW); - - begin_x = forest.create(scn, begin_x, "8"); - - begin_x = hallway.create(scn, begin_x, 16, Color::MAGENTA);*/ - GameObject scripts = scn.new_object("scrips_background", "background"); scripts.add_component().set_script(); scripts.add_component().set_script(); -- cgit v1.2.3