From 999e1b928aa632e80521651f14013c267af604dc Mon Sep 17 00:00:00 2001 From: Max-001 Date: Sat, 21 Dec 2024 11:19:52 +0100 Subject: Moved file to sub directory --- game/AquariumSubScene.cpp | 135 ---------- game/AquariumSubScene.h | 13 - game/BackgroundSubScene.cpp | 37 --- game/BackgroundSubScene.h | 10 - game/CMakeLists.txt | 12 +- game/ForestParallaxScript.cpp | 28 -- game/ForestParallaxScript.h | 15 -- game/ForestSubScene.cpp | 131 --------- game/ForestSubScene.h | 15 -- game/GameScene.cpp | 3 +- game/HallwaySubScene.cpp | 128 --------- game/HallwaySubScene.h | 21 -- game/StartSubScene.cpp | 442 ------------------------------- game/StartSubScene.h | 20 -- game/background/AquariumSubScene.cpp | 129 +++++++++ game/background/AquariumSubScene.h | 13 + game/background/BackgroundSubScene.cpp | 37 +++ game/background/BackgroundSubScene.h | 10 + game/background/ForestParallaxScript.cpp | 28 ++ game/background/ForestParallaxScript.h | 15 ++ game/background/ForestSubScene.cpp | 131 +++++++++ game/background/ForestSubScene.h | 15 ++ game/background/HallwaySubScene.cpp | 128 +++++++++ game/background/HallwaySubScene.h | 21 ++ game/background/StartSubScene.cpp | 442 +++++++++++++++++++++++++++++++ game/background/StartSubScene.h | 20 ++ 26 files changed, 997 insertions(+), 1002 deletions(-) delete mode 100644 game/AquariumSubScene.cpp delete mode 100644 game/AquariumSubScene.h delete mode 100644 game/BackgroundSubScene.cpp delete mode 100644 game/BackgroundSubScene.h delete mode 100644 game/ForestParallaxScript.cpp delete mode 100644 game/ForestParallaxScript.h delete mode 100644 game/ForestSubScene.cpp delete mode 100644 game/ForestSubScene.h delete mode 100644 game/HallwaySubScene.cpp delete mode 100644 game/HallwaySubScene.h delete mode 100644 game/StartSubScene.cpp delete mode 100644 game/StartSubScene.h create mode 100644 game/background/AquariumSubScene.cpp create mode 100644 game/background/AquariumSubScene.h create mode 100644 game/background/BackgroundSubScene.cpp create mode 100644 game/background/BackgroundSubScene.h create mode 100644 game/background/ForestParallaxScript.cpp create mode 100644 game/background/ForestParallaxScript.h create mode 100644 game/background/ForestSubScene.cpp create mode 100644 game/background/ForestSubScene.h create mode 100644 game/background/HallwaySubScene.cpp create mode 100644 game/background/HallwaySubScene.h create mode 100644 game/background/StartSubScene.cpp create mode 100644 game/background/StartSubScene.h (limited to 'game') diff --git a/game/AquariumSubScene.cpp b/game/AquariumSubScene.cpp deleted file mode 100644 index f4b20f6..0000000 --- a/game/AquariumSubScene.cpp +++ /dev/null @@ -1,135 +0,0 @@ -#include "AquariumSubScene.h" - -#include -#include -#include -#include -#include - -using namespace crepe; -using namespace std; - -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)); - Asset aquarium_begin_asset{ - "asset/background/aquarium/glassTubeFG_1_TVOS.png"}; - aquarium_begin.add_component(aquarium_begin_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 0, - .size = vec2(0, 800), - }); - begin_x += 600; - - GameObject aquarium_middle_1 - = scn.new_object("aquarium_middle", "background", 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, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 2, - .size = vec2(0, 800), - }); - begin_x += 400; - - this->add_background(scn, begin_x - 200); - - GameObject aquarium_middle_2 - = scn.new_object("aquarium_middle", "background", 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, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 3, - .size = vec2(0, 800), - }); - begin_x += 400; - - GameObject aquarium_middle_3 - = scn.new_object("aquarium_middle", "background", 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, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 4, - .size = vec2(0, 800), - }); - begin_x += 400; - - this->add_background(scn, begin_x - 200); - - GameObject aquarium_middle_4 - = scn.new_object("aquarium_middle", "background", 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, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 5, - .size = vec2(0, 800), - }); - begin_x += 600; - - this->add_background(scn, begin_x); - - GameObject aquarium_end = scn.new_object("aquarium_end", "background", vec2(begin_x, 0)); - Asset aquarium_end_asset{ - "asset/background/aquarium/glassTubeFG_2_TVOS.png"}; - aquarium_end.add_component(aquarium_end_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 1, - .size = vec2(0, 800), - }); - begin_x += 600; - - return 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)); - Asset bg_1_1_asset{"asset/background/aquarium/AquariumBG1_1_TVOS.png"}; - bg_1.add_component(bg_1_1_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 2, - .size = vec2(0, 400), - .position_offset = vec2(-200, 100), - }); - Asset bg_1_2_asset{"asset/background/aquarium/AquariumBG1_2_TVOS.png"}; - bg_1.add_component(bg_1_2_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 2, - .size = vec2(0, 400), - .position_offset = vec2(200, 100), - }); - GameObject bg_2 = scn.new_object("aquarium_bg_2", "aquarium_background", vec2(begin_x, 0)); - Asset bg_2_1_asset{"asset/background/aquarium/AquariumBG2_1_TVOS.png"}; - bg_2.add_component(bg_2_1_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 1, - .size = vec2(0, 400), - .position_offset = vec2(200, -50), - }); - Asset bg_2_2_asset{"asset/background/aquarium/AquariumBG2_2_TVOS.png"}; - bg_2.add_component(bg_2_2_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 1, - .size = vec2(0, 400), - .position_offset = vec2(-200, -50), - }); - GameObject bg_3 = scn.new_object("aquarium_bg_3", "aquarium_background", vec2(begin_x, 0)); - Asset bg_3_1_asset{"asset/background/aquarium/AquariumBG3_1_TVOS.png"}; - bg_3.add_component(bg_3_1_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 0, - .size = vec2(0, 400), - .position_offset = vec2(200, -200), - }); - Asset bg_3_2_asset{"asset/background/aquarium/AquariumBG3_2_TVOS.png"}; - bg_3.add_component(bg_3_2_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 0, - .size = vec2(0, 400), - .position_offset = vec2(-200, -200), - }); -} diff --git a/game/AquariumSubScene.h b/game/AquariumSubScene.h deleted file mode 100644 index 2a188bc..0000000 --- a/game/AquariumSubScene.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -namespace crepe { -class Scene; -} - -class AquariumSubScene { -public: - float create(crepe::Scene & scn, float begin_x); - -private: - void add_background(crepe::Scene & scn, float begin_x); -}; diff --git a/game/BackgroundSubScene.cpp b/game/BackgroundSubScene.cpp deleted file mode 100644 index 6fdc598..0000000 --- a/game/BackgroundSubScene.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "BackgroundSubScene.h" -#include "AquariumSubScene.h" -#include "ForestSubScene.h" -#include "HallwaySubScene.h" -#include "StartSubScene.h" - -#include - -using namespace crepe; -using namespace std; - -BackgroundSubScene::BackgroundSubScene(Scene & scn) { - StartSubScene start; - HallwaySubScene hallway; - ForestSubScene forest; - AquariumSubScene aquarium; - - float begin_x = 400; - - begin_x = start.create(scn, begin_x); - - begin_x = hallway.create(scn, begin_x, 1, Color::YELLOW); - - begin_x = forest.create(scn, begin_x, "1"); - - 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 = forest.create(scn, begin_x, "2"); - - begin_x = hallway.create(scn, begin_x, 4, Color::GREEN); - - begin_x = aquarium.create(scn, begin_x); -} diff --git a/game/BackgroundSubScene.h b/game/BackgroundSubScene.h deleted file mode 100644 index 06bdac4..0000000 --- a/game/BackgroundSubScene.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -namespace crepe { -class Scene; -} - -class BackgroundSubScene { -public: - BackgroundSubScene(crepe::Scene & scn); -}; diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index dc55523..937b5e6 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -9,17 +9,17 @@ project(game C CXX) add_subdirectory(../src crepe) add_executable(main - AquariumSubScene.cpp - BackgroundSubScene.cpp - ForestParallaxScript.cpp - ForestSubScene.cpp + background/AquariumSubScene.cpp + background/BackgroundSubScene.cpp + background/ForestParallaxScript.cpp + background/ForestSubScene.cpp GameScene.cpp - HallwaySubScene.cpp + background/HallwaySubScene.cpp MoveCameraManualyScript.cpp PlayerScript.cpp PlayerSubScene.cpp StartGameScript.cpp - StartSubScene.cpp + background/StartSubScene.cpp main.cpp ) diff --git a/game/ForestParallaxScript.cpp b/game/ForestParallaxScript.cpp deleted file mode 100644 index 27e30eb..0000000 --- a/game/ForestParallaxScript.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "ForestParallaxScript.h" - -using namespace crepe; -using namespace std; - -ForestParallaxScript::ForestParallaxScript(float begin_x, float end_x, - std::string unique_bg_name) - : begin_x(begin_x), - end_x(end_x), - name(unique_bg_name) {} - -void ForestParallaxScript::fixed_update(crepe::duration_t dt) { - RefVector vec_2 - = this->get_components_by_name("forest_bg_2_" + name); - RefVector vec_3 - = this->get_components_by_name("forest_bg_3_" + name); - - for (Transform & t : vec_2) { - if (t.position.x > end_x - 400) { - t.position.x = begin_x - 400; - } - } - for (Transform & t : vec_3) { - if (t.position.x > end_x - 400) { - t.position.x = begin_x - 400; - } - } -} diff --git a/game/ForestParallaxScript.h b/game/ForestParallaxScript.h deleted file mode 100644 index a65a684..0000000 --- a/game/ForestParallaxScript.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include - -class ForestParallaxScript : public crepe::Script { -public: - ForestParallaxScript(float begin_x, float end_x, std::string unique_bg_name); - - void fixed_update(crepe::duration_t dt); - -private: - const float begin_x; - const float end_x; - const std::string name; -}; diff --git a/game/ForestSubScene.cpp b/game/ForestSubScene.cpp deleted file mode 100644 index 810ef17..0000000 --- a/game/ForestSubScene.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include "ForestSubScene.h" -#include "ForestParallaxScript.h" - -#include -#include -#include -#include -#include -#include -#include - -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"); - 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)); - Asset begin_asset{"asset/background/forest/forestFG_1_TVOS.png"}; - begin.add_component(begin_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 0, - .size = vec2(0, 800), - }); - begin_x += 800; - - this->add_background(scn, begin_x, unique_bg_name); - - GameObject middle_1 = scn.new_object("forest_middle", "background", vec2(begin_x, 0)); - Asset middle_1_asset{"asset/background/forest/forestFG_3_TVOS.png"}; - middle_1.add_component(middle_1_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 2, - .size = vec2(0, 800), - }); - begin_x += 800; - - this->add_background(scn, begin_x, unique_bg_name); - - GameObject middle_2 = scn.new_object("forest_middle", "background", vec2(begin_x, 0)); - Asset middle_2_asset{"asset/background/forest/forestFG_3_TVOS.png"}; - middle_2.add_component(middle_2_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 3, - .size = vec2(0, 800), - }); - begin_x += 800; - - this->add_background(scn, begin_x, unique_bg_name); - - GameObject end = scn.new_object("forest_end", "background", vec2(begin_x, 0)); - Asset end_asset{"asset/background/forest/forestFG_2_TVOS.png"}; - end.add_component(end_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 1, - .size = vec2(0, 800), - }); - begin_x += 600; - - this->add_background(scn, begin_x + 200, unique_bg_name); - - return begin_x; -} - -void ForestSubScene::add_background(Scene & scn, float begin_x, std::string name) { - GameObject bg_1 - = scn.new_object("forest_bg_1_" + name, "forest_background", vec2(begin_x, 0)); - Asset bg_1_asset{"asset/background/forest/forestBG1_1_TVOS.png"}; - bg_1.add_component(bg_1_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 2, - .size = vec2(0, 800), - }); - GameObject bg_2 - = scn.new_object("forest_bg_2_" + name, "forest_background", vec2(begin_x, 0)); - Asset bg_2_1_asset{"asset/background/forest/forestBG2_1_TVOS.png"}; - bg_2.add_component(bg_2_1_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 1, - .size = vec2(0, 400), - .position_offset = vec2(200, 0), - }); - Asset bg_2_2_asset{"asset/background/forest/forestBG2_2_TVOS.png"}; - bg_2.add_component(bg_2_2_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 1, - .size = vec2(0, 400), - .position_offset = vec2(-200, 0), - }); - GameObject bg_3 - = scn.new_object("forest_bg_3_" + name, "forest_background", vec2(begin_x, 0)); - Asset bg_3_1_asset{"asset/background/forest/forestBG3_1_TVOS.png"}; - bg_3.add_component(bg_3_1_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 0, - .size = vec2(0, 200), - .position_offset = vec2(300, 0), - }); - Asset bg_3_2_asset{"asset/background/forest/forestBG3_2_TVOS.png"}; - bg_3.add_component(bg_3_2_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 0, - .size = vec2(0, 200), - .position_offset = vec2(100, 0), - }); - Asset bg_3_3_asset{"asset/background/forest/forestBG3_3_TVOS.png"}; - bg_3.add_component(bg_3_3_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 0, - .size = vec2(0, 200), - .position_offset = vec2(-100, 0), - }); - Asset bg_3_4_asset{"asset/background/forest/forestBG3_4_TVOS.png"}; - bg_3.add_component(bg_3_4_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 0, - .size = vec2(0, 200), - .position_offset = vec2(-300, 0), - }); - - bg_2.add_component(Rigidbody::Data{ - .linear_velocity = vec2(30, 0), - }); - bg_3.add_component(Rigidbody::Data{ - .linear_velocity = vec2(40, 0), - }); -} diff --git a/game/ForestSubScene.h b/game/ForestSubScene.h deleted file mode 100644 index 0a04001..0000000 --- a/game/ForestSubScene.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include - -namespace crepe { -class Scene; -} - -class ForestSubScene { -public: - float create(crepe::Scene & scn, float begin_x, std::string unique_bg_name); - -private: - void add_background(crepe::Scene & scn, float begin_x, std::string name); -}; diff --git a/game/GameScene.cpp b/game/GameScene.cpp index c280474..9606244 100644 --- a/game/GameScene.cpp +++ b/game/GameScene.cpp @@ -1,9 +1,10 @@ #include "GameScene.h" -#include "BackgroundSubScene.h" #include "MoveCameraManualyScript.h" #include "PlayerSubScene.h" #include "StartGameScript.h" +#include "background/BackgroundSubScene.h" + #include #include #include diff --git a/game/HallwaySubScene.cpp b/game/HallwaySubScene.cpp deleted file mode 100644 index 486b8c6..0000000 --- a/game/HallwaySubScene.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "HallwaySubScene.h" - -#include -#include -#include -#include -#include - -using namespace crepe; -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)); - Asset begin_asset{"asset/background/hallway/hallway1FG_1_TVOS.png"}; - begin.add_component(begin_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 0, - .size = vec2(0, 800), - }); - begin_x += 600; - - this->add_sector_number(begin, vec2(-200, 0), sector_num, sector_color); - 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)); - Asset middle_asset{"asset/background/hallway/hallway1FG_2_TVOS.png"}; - middle_1.add_component(middle_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 2, - .size = vec2(0, 800), - }); - begin_x += 600; - - GameObject middle_2 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); - Asset middle_asset_2{"asset/background/hallway/hallway1FG_2_TVOS.png"}; - middle_2.add_component(middle_asset_2, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 3, - .size = vec2(0, 800), - }); - begin_x += 200; - - GameObject middle_3 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); - Asset middle_asset_3{"asset/background/hallway/hallway1FG_2_TVOS.png"}; - middle_3.add_component(middle_asset_3, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 4, - .size = vec2(0, 800), - }); - begin_x += 400; - - this->add_lamp(middle_3, vec2(0, -120)); - - GameObject middle_4 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); - Asset middle_asset_4{"asset/background/hallway/hallway1FG_2_TVOS.png"}; - middle_4.add_component(middle_asset_4, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 5, - .size = vec2(0, 800), - }); - begin_x += 600; - - GameObject end = scn.new_object("hallway_end", "background", vec2(begin_x, 0)); - Asset end_asset{"asset/background/hallway/hallway1FG_1_TVOS.png"}; - end.add_component(end_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 1, - .size = vec2(0, 800), - }); - begin_x += 600; - - return begin_x; -} - -void HallwaySubScene::add_lamp(GameObject & obj, vec2 offset, unsigned int fps) { - Asset lamp_asset{"asset/background/hallway/alarmLight_TVOS.png"}; - obj.add_component(lamp_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 0, - .size = vec2(0, 100), - .position_offset = offset, - }); - Asset lamp_glow_asset{"asset/background/hallway/alarmGlow_TVOS.png"}; - Sprite & lamp_glow_sprite = obj.add_component( - lamp_glow_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 1, - .size = vec2(0, 300), - .position_offset = offset - vec2(65, -30), - }); - obj.add_component(lamp_glow_sprite, ivec2(422, 384), uvec2(6, 1), - Animator::Data{ - .fps = fps, - .looping = true, - }); -} - -void HallwaySubScene::add_sector_number(GameObject & obj, vec2 offset, unsigned int sector_num, - Color sector_color) { - Asset sector_text_asset{"asset/background/hallway/sectorText_TVOS.png"}; - obj.add_component(sector_text_asset, Sprite::Data{ - .color = sector_color, - .sorting_in_layer = 5, - .order_in_layer = 0, - .size = vec2(0, 100), - .position_offset = offset, - }); - Asset sector_num_asset{"asset/background/hallway/sectorNumbers_TVOS.png"}; - Sprite & sector_num_sprite = obj.add_component( - sector_num_asset, Sprite::Data{ - .color = sector_color, - .sorting_in_layer = 5, - .order_in_layer = 0, - .size = vec2(0, 100), - .position_offset = offset + vec2(200, 0), - }); - Animator & sector_num_anim = obj.add_component( - sector_num_sprite, ivec2(256, 128), uvec2(4, 4), Animator::Data{}); - int column = (sector_num - 1) / 4; - int row = (sector_num - 1) % 4; - sector_num_anim.set_anim(column); - for (int i = 0; i < row; i++) { - sector_num_anim.next_anim(); - } - sector_num_anim.pause(); -} diff --git a/game/HallwaySubScene.h b/game/HallwaySubScene.h deleted file mode 100644 index acc9329..0000000 --- a/game/HallwaySubScene.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include - -namespace crepe { -class Scene; -class GameObject; -class Color; -} // namespace crepe - -class HallwaySubScene { -public: - float create(crepe::Scene & scn, float begin_x, unsigned int sector_num, - crepe::Color sector_color); - -private: - void add_lamp(crepe::GameObject & obj, crepe::vec2 offset, unsigned int fps = 10); - - void add_sector_number(crepe::GameObject & obj, crepe::vec2 offset, - unsigned int sector_num, crepe::Color sector_color); -}; diff --git a/game/StartSubScene.cpp b/game/StartSubScene.cpp deleted file mode 100644 index 5d810c2..0000000 --- a/game/StartSubScene.cpp +++ /dev/null @@ -1,442 +0,0 @@ -#include "StartSubScene.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace crepe; -using namespace std; - -float StartSubScene::create(Scene & scn, float begin_x) { - this->create_wall_fragments(scn, begin_x - 300); - - GameObject begin = scn.new_object("start_begin", "background", vec2(begin_x, 0)); - Asset begin_asset{"asset/background/start/titleFG_1_TVOS.png"}; - begin.add_component(begin_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 0, - .size = vec2(0, 800), - }); - GameObject hole = scn.new_object("start_hole", "background", vec2(begin_x - 250, 140)); - Asset hole_asset{"asset/background/start/titleWallHole.png"}; - Sprite & hole_sprite = hole.add_component(hole_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 1, - .size = vec2(0, 200), - }); - hole_sprite.active = false; - begin_x += 700; - - this->add_table(begin, vec2(-150, 150)); - this->add_light(begin, vec2(-125, -150)); - this->add_jetpack_stand(begin, vec2(-125, 200)); - - GameObject end = scn.new_object("start_end", "background", vec2(begin_x, 0)); - Asset end_asset{"asset/background/start/titleFG_2_TVOS.png"}; - end.add_component(end_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 1, - .size = vec2(0, 800), - }); - begin_x += 100; - - this->add_lamp(end, vec2(-350, -95)); - - return begin_x; -} - -void StartSubScene::add_lamp(GameObject & obj, vec2 offset, unsigned int fps) { - Asset lamp_asset{"asset/background/start/alarmLight_TVOS.png"}; - obj.add_component(lamp_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 0, - .size = vec2(0, 100), - .position_offset = offset, - }); - Asset lamp_glow_asset{"asset/background/start/alarmGlow_TVOS.png"}; - Sprite & lamp_glow_sprite = obj.add_component( - lamp_glow_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 1, - .size = vec2(0, 300), - .position_offset = offset - vec2(65, -55), - }); - lamp_glow_sprite.active = false; - obj.add_component(lamp_glow_sprite, ivec2(422, 384), uvec2(6, 1), - Animator::Data{ - .fps = fps, - .looping = true, - }); -} - -void StartSubScene::add_table(GameObject & obj, vec2 offset) { - Asset table_asset{"asset/background/start/table.png"}; - obj.add_component(table_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 0, - .size = vec2(0, 100), - .position_offset = offset, - }); - Asset gramophone_asset{"asset/background/start/gramophone_TVOS.png"}; - Sprite & gramophone_sprite = obj.add_component( - gramophone_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 1, - .size = vec2(0, 100), - .position_offset = offset + vec2(0, -50), - }); - obj.add_component(gramophone_sprite, ivec2(64, 128), uvec2(2, 1), - Animator::Data{ - .fps = 10, - .looping = true, - }); -} - -void StartSubScene::add_light(crepe::GameObject & obj, crepe::vec2 offset) { - Asset light_asset{"asset/background/start/title_light_TVOS.png"}; - obj.add_component(light_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 0, - .size = vec2(0, 200), - .position_offset = offset, - }); - Asset light_glow_asset{"asset/background/start/lightEffect2.png"}; - obj.add_component(light_glow_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 1, - .size = vec2(0, 100), - .position_offset = offset + vec2(0, 75), - }); - Asset light_effect_asset{"asset/background/start/lightEffect.png"}; - obj.add_component(light_effect_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 0, - .size = vec2(0, 100), - .position_offset = offset + vec2(0, 350), - }); -} - -void StartSubScene::add_jetpack_stand(crepe::GameObject & obj, crepe::vec2 offset) { - Asset jetpack_stand_asset{"asset/background/start/JetpackStand.png"}; - Sprite & jetpeck_stand_sprite - = obj.add_component(jetpack_stand_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 1, - .size = vec2(0, 70), - .position_offset = offset, - }); - obj.add_component(jetpeck_stand_sprite, ivec2(34, 46), uvec2(2, 1), - Animator::Data{ - .fps = 10, - .looping = true, - }) - .pause(); - Asset do_not_steal = {"asset/background/start/doNotTouchSign_TVOS.png"}; - obj.add_component(do_not_steal, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 1, - .size = vec2(0, 100), - .position_offset = offset + vec2(-75, -25), - }); -} - -void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { - GameObject frag_1 = scn.new_object("frag_1", "wall_fragment", vec2(begin_x, 200)); - Asset frag_1_asset{"asset/background/start/StartWall_frag1.png"}; - Sprite & frag_1_sprite - = frag_1.add_component(frag_1_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); - frag_1_sprite.active = false; - Rigidbody & frag_1_rb = frag_1.add_component(Rigidbody::Data{ - .gravity_scale = 10, - .linear_velocity = vec2(400, 400), - .linear_velocity_coefficient = vec2(0.5, 0.6), - .angular_velocity = 500, - .angular_velocity_coefficient = 0.55, - .elasticity_coefficient = 0.5, - .collision_layer = 5, - }); - frag_1_rb.active = false; - frag_1.add_component(25); - - GameObject frag_2 = scn.new_object("frag_2", "wall_fragment", vec2(begin_x, 180)); - Asset frag_2_asset{"asset/background/start/StartWall_frag2.png"}; - Sprite & frag_2_sprite - = frag_2.add_component(frag_2_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); - frag_2_sprite.active = false; - Rigidbody & frag_2_rb = frag_2.add_component(Rigidbody::Data{ - .gravity_scale = 20, - .linear_velocity = vec2(400, 400), - .linear_velocity_coefficient = vec2(0.35, 0.4), - .angular_velocity = 400, - .angular_velocity_coefficient = 0.55, - .elasticity_coefficient = 0.5, - .collision_layer = 5, - }); - frag_2_rb.active = false; - frag_2.add_component(55); - - GameObject frag_3 = scn.new_object("frag_3", "wall_fragment", vec2(begin_x, 170)); - Asset frag_3_asset{"asset/background/start/StartWall_frag3.png"}; - Sprite & frag_3_sprite - = frag_3.add_component(frag_3_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); - frag_3_sprite.active = false; - Rigidbody & frag_3_rb = frag_3.add_component(Rigidbody::Data{ - .gravity_scale = 30, - .linear_velocity = vec2(400, 400), - .linear_velocity_coefficient = vec2(0.3, 0.3), - .angular_velocity = 300, - .angular_velocity_coefficient = 0.55, - .elasticity_coefficient = 0.5, - .collision_layer = 5, - }); - frag_3_rb.active = false; - frag_3.add_component(35); - - GameObject frag_4 = scn.new_object("frag_4", "wall_fragment", vec2(begin_x, 160)); - Asset frag_4_asset{"asset/background/start/StartWall_frag4.png"}; - Sprite & frag_4_sprite - = frag_4.add_component(frag_4_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); - frag_4_sprite.active = false; - Rigidbody & frag_4_rb = frag_4.add_component(Rigidbody::Data{ - .gravity_scale = 40, - .linear_velocity = vec2(700, 400), - .linear_velocity_coefficient = vec2(0.2, 0.2), - .angular_velocity = 200, - .angular_velocity_coefficient = 0.55, - .elasticity_coefficient = 0.5, - .collision_layer = 5, - }); - frag_4_rb.active = false; - frag_4.add_component(60); - - GameObject frag_5 = scn.new_object("frag_5", "wall_fragment", vec2(begin_x, 150)); - Asset frag_5_asset{"asset/background/start/StartWall_frag5.png"}; - Sprite & frag_5_sprite - = frag_5.add_component(frag_5_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); - frag_5_sprite.active = false; - Rigidbody & frag_5_rb = frag_5.add_component(Rigidbody::Data{ - .gravity_scale = 50, - .linear_velocity = vec2(600, 800), - .linear_velocity_coefficient = vec2(0.25, 0.15), - .angular_velocity = 100, - .angular_velocity_coefficient = 0.55, - .elasticity_coefficient = 0.5, - .collision_layer = 5, - }); - frag_5_rb.active = false; - frag_5.add_component(5); - - GameObject frag_6 = scn.new_object("frag_6", "wall_fragment", vec2(begin_x, 140)); - Asset frag_6_asset{"asset/background/start/StartWall_frag6.png"}; - Sprite & frag_6_sprite - = frag_6.add_component(frag_6_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); - frag_6_sprite.active = false; - Rigidbody & frag_6_rb = frag_6.add_component(Rigidbody::Data{ - .gravity_scale = 30, - .linear_velocity = vec2(300, 800), - .linear_velocity_coefficient = vec2(0.35, 0.25), - .angular_velocity = 100, - .angular_velocity_coefficient = 0.55, - .elasticity_coefficient = 0.5, - .collision_layer = 5, - }); - frag_6_rb.active = false; - frag_6.add_component(30); - - GameObject frag_7 = scn.new_object("frag_7", "wall_fragment", vec2(begin_x, 130)); - Asset frag_7_asset{"asset/background/start/StartWall_frag7.png"}; - Sprite & frag_7_sprite - = frag_7.add_component(frag_7_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); - frag_7_sprite.active = false; - Rigidbody & frag_7_rb = frag_7.add_component(Rigidbody::Data{ - .gravity_scale = 20, - .linear_velocity = vec2(400, 500), - .linear_velocity_coefficient = vec2(0.45, 0.6), - .angular_velocity = 800, - .angular_velocity_coefficient = 0.55, - .elasticity_coefficient = 0.5, - .collision_layer = 5, - }); - frag_7_rb.active = false; - frag_7.add_component(45); - - GameObject frag_8 = scn.new_object("frag_8", "wall_fragment", vec2(begin_x, 120)); - Asset frag_8_asset{"asset/background/start/StartWall_frag8.png"}; - Sprite & frag_8_sprite - = frag_8.add_component(frag_8_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); - frag_8_sprite.active = false; - Rigidbody & frag_8_rb = frag_8.add_component(Rigidbody::Data{ - .gravity_scale = 30, - .linear_velocity = vec2(400, 400), - .linear_velocity_coefficient = vec2(0.5, 0.6), - .angular_velocity = 500, - .angular_velocity_coefficient = 0.55, - .elasticity_coefficient = 0.5, - .collision_layer = 5, - }); - frag_8_rb.active = false; - frag_8.add_component(25); - - GameObject frag_9 = scn.new_object("frag_9", "wall_fragment", vec2(begin_x, 110)); - Asset frag_9_asset{"asset/background/start/StartWall_frag9.png"}; - Sprite & frag_9_sprite - = frag_9.add_component(frag_9_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); - frag_9_sprite.active = false; - Rigidbody & frag_9_rb = frag_9.add_component(Rigidbody::Data{ - .gravity_scale = 40, - .linear_velocity = vec2(200, 400), - .linear_velocity_coefficient = vec2(0.5, 0.25), - .angular_velocity = 500, - .angular_velocity_coefficient = 0.55, - .elasticity_coefficient = 0.5, - .collision_layer = 5, - }); - frag_9_rb.active = false; - frag_9.add_component(15); - - GameObject frag_10 = scn.new_object("frag_10", "wall_fragment", vec2(begin_x, 100)); - Asset frag_10_asset{"asset/background/start/StartWall_frag10.png"}; - Sprite & frag_10_sprite - = frag_10.add_component(frag_10_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); - frag_10_sprite.active = false; - Rigidbody & frag_10_rb = frag_10.add_component(Rigidbody::Data{ - .gravity_scale = 50, - .linear_velocity = vec2(400, 900), - .linear_velocity_coefficient = vec2(0.35, 0.4), - .angular_velocity = 300, - .angular_velocity_coefficient = 0.55, - .elasticity_coefficient = 0.5, - .collision_layer = 5, - }); - frag_10_rb.active = false; - frag_10.add_component(60); - - GameObject frag_11 = scn.new_object("frag_11", "wall_fragment", vec2(begin_x, 90)); - Asset frag_11_asset{"asset/background/start/StartWall_frag11.png"}; - Sprite & frag_11_sprite - = frag_11.add_component(frag_11_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); - frag_11_sprite.active = false; - Rigidbody & frag_11_rb = frag_11.add_component(Rigidbody::Data{ - .gravity_scale = 60, - .linear_velocity = vec2(600, 800), - .linear_velocity_coefficient = vec2(0.3, 0.3), - .angular_velocity = 200, - .angular_velocity_coefficient = 0.55, - .elasticity_coefficient = 0.5, - .collision_layer = 5, - }); - frag_11_rb.active = false; - frag_11.add_component(5); - - GameObject frag_12 = scn.new_object("frag_12", "wall_fragment", vec2(begin_x, 80)); - Asset frag_12_asset{"asset/background/start/StartWall_frag12.png"}; - Sprite & frag_12_sprite - = frag_12.add_component(frag_12_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); - frag_12_sprite.active = false; - Rigidbody & frag_12_rb = frag_12.add_component(Rigidbody::Data{ - .gravity_scale = 70, - .linear_velocity = vec2(500, 800), - .linear_velocity_coefficient = vec2(0.25, 0.15), - .angular_velocity = 100, - .angular_velocity_coefficient = 0.55, - .elasticity_coefficient = 0.5, - .collision_layer = 5, - }); - frag_12_rb.active = false; - frag_12.add_component(50); - - GameObject smoke_particles_1 - = scn.new_object("smoke_particles", "particle_emitter", vec2(begin_x - 100, 200)); - Asset smoke_asset_1{"asset/particles/smoke.png"}; - Sprite & smoke_sprite_1 = smoke_particles_1.add_component( - smoke_asset_1, Sprite::Data{ - .color = Color(255, 255, 255, 50), - .sorting_in_layer = 15, - .order_in_layer = 0, - .size = vec2(0, 100), - }); - ParticleEmitter & emitter_1 = smoke_particles_1.add_component( - smoke_sprite_1, ParticleEmitter::Data{ - .emission_rate = 20, - .min_speed = 40, - .max_speed = 100, - .min_angle = -30, - .max_angle = 10, - .end_lifespan = 4, - }); - emitter_1.active = false; - - GameObject smoke_particles_2 - = scn.new_object("smoke_particles", "particle_emitter", vec2(begin_x - 100, 200)); - Asset smoke_asset_2{"asset/particles/smoke.png"}; - Sprite & smoke_sprite_2 = smoke_particles_2.add_component( - smoke_asset_2, Sprite::Data{ - .color = Color(255, 255, 255, 50), - .sorting_in_layer = 15, - .order_in_layer = 0, - .size = vec2(0, 70), - }); - ParticleEmitter & emitter_2 = smoke_particles_2.add_component( - smoke_sprite_2, ParticleEmitter::Data{ - .emission_rate = 30, - .min_speed = 40, - .max_speed = 100, - .min_angle = -45, - .max_angle = 5, - .end_lifespan = 3, - }); - emitter_2.active = false; -} diff --git a/game/StartSubScene.h b/game/StartSubScene.h deleted file mode 100644 index c83e3d5..0000000 --- a/game/StartSubScene.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include - -namespace crepe { -class Scene; -class GameObject; -} // namespace crepe - -class StartSubScene { -public: - float create(crepe::Scene & scn, float begin_x); - -private: - void add_lamp(crepe::GameObject & obj, crepe::vec2 offset, unsigned int fps = 10); - void add_table(crepe::GameObject & obj, crepe::vec2 offset); - void add_light(crepe::GameObject & obj, crepe::vec2 offset); - void add_jetpack_stand(crepe::GameObject & obj, crepe::vec2 offset); - void create_wall_fragments(crepe::Scene & scn, float begin_x); -}; diff --git a/game/background/AquariumSubScene.cpp b/game/background/AquariumSubScene.cpp new file mode 100644 index 0000000..40e22b7 --- /dev/null +++ b/game/background/AquariumSubScene.cpp @@ -0,0 +1,129 @@ +#include "AquariumSubScene.h" + +#include +#include +#include +#include +#include + +using namespace crepe; +using namespace std; + +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)); + Asset aquarium_begin_asset{"asset/background/aquarium/glassTubeFG_1_TVOS.png"}; + aquarium_begin.add_component(aquarium_begin_asset, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 0, + .size = vec2(0, 800), + }); + begin_x += 600; + + GameObject aquarium_middle_1 + = scn.new_object("aquarium_middle", "background", 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, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 2, + .size = vec2(0, 800), + }); + begin_x += 400; + + this->add_background(scn, begin_x - 200); + + GameObject aquarium_middle_2 + = scn.new_object("aquarium_middle", "background", 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, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 3, + .size = vec2(0, 800), + }); + begin_x += 400; + + GameObject aquarium_middle_3 + = scn.new_object("aquarium_middle", "background", 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, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 4, + .size = vec2(0, 800), + }); + begin_x += 400; + + this->add_background(scn, begin_x - 200); + + GameObject aquarium_middle_4 + = scn.new_object("aquarium_middle", "background", 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, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 5, + .size = vec2(0, 800), + }); + begin_x += 600; + + this->add_background(scn, begin_x); + + GameObject aquarium_end = scn.new_object("aquarium_end", "background", vec2(begin_x, 0)); + Asset aquarium_end_asset{"asset/background/aquarium/glassTubeFG_2_TVOS.png"}; + aquarium_end.add_component(aquarium_end_asset, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 1, + .size = vec2(0, 800), + }); + begin_x += 600; + + return 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)); + Asset bg_1_1_asset{"asset/background/aquarium/AquariumBG1_1_TVOS.png"}; + bg_1.add_component(bg_1_1_asset, Sprite::Data{ + .sorting_in_layer = 3, + .order_in_layer = 2, + .size = vec2(0, 400), + .position_offset = vec2(-200, 100), + }); + Asset bg_1_2_asset{"asset/background/aquarium/AquariumBG1_2_TVOS.png"}; + bg_1.add_component(bg_1_2_asset, Sprite::Data{ + .sorting_in_layer = 3, + .order_in_layer = 2, + .size = vec2(0, 400), + .position_offset = vec2(200, 100), + }); + GameObject bg_2 = scn.new_object("aquarium_bg_2", "aquarium_background", vec2(begin_x, 0)); + Asset bg_2_1_asset{"asset/background/aquarium/AquariumBG2_1_TVOS.png"}; + bg_2.add_component(bg_2_1_asset, Sprite::Data{ + .sorting_in_layer = 3, + .order_in_layer = 1, + .size = vec2(0, 400), + .position_offset = vec2(200, -50), + }); + Asset bg_2_2_asset{"asset/background/aquarium/AquariumBG2_2_TVOS.png"}; + bg_2.add_component(bg_2_2_asset, Sprite::Data{ + .sorting_in_layer = 3, + .order_in_layer = 1, + .size = vec2(0, 400), + .position_offset = vec2(-200, -50), + }); + GameObject bg_3 = scn.new_object("aquarium_bg_3", "aquarium_background", vec2(begin_x, 0)); + Asset bg_3_1_asset{"asset/background/aquarium/AquariumBG3_1_TVOS.png"}; + bg_3.add_component(bg_3_1_asset, Sprite::Data{ + .sorting_in_layer = 3, + .order_in_layer = 0, + .size = vec2(0, 400), + .position_offset = vec2(200, -200), + }); + Asset bg_3_2_asset{"asset/background/aquarium/AquariumBG3_2_TVOS.png"}; + bg_3.add_component(bg_3_2_asset, Sprite::Data{ + .sorting_in_layer = 3, + .order_in_layer = 0, + .size = vec2(0, 400), + .position_offset = vec2(-200, -200), + }); +} diff --git a/game/background/AquariumSubScene.h b/game/background/AquariumSubScene.h new file mode 100644 index 0000000..2a188bc --- /dev/null +++ b/game/background/AquariumSubScene.h @@ -0,0 +1,13 @@ +#pragma once + +namespace crepe { +class Scene; +} + +class AquariumSubScene { +public: + float create(crepe::Scene & scn, float begin_x); + +private: + void add_background(crepe::Scene & scn, float begin_x); +}; diff --git a/game/background/BackgroundSubScene.cpp b/game/background/BackgroundSubScene.cpp new file mode 100644 index 0000000..6fdc598 --- /dev/null +++ b/game/background/BackgroundSubScene.cpp @@ -0,0 +1,37 @@ +#include "BackgroundSubScene.h" +#include "AquariumSubScene.h" +#include "ForestSubScene.h" +#include "HallwaySubScene.h" +#include "StartSubScene.h" + +#include + +using namespace crepe; +using namespace std; + +BackgroundSubScene::BackgroundSubScene(Scene & scn) { + StartSubScene start; + HallwaySubScene hallway; + ForestSubScene forest; + AquariumSubScene aquarium; + + float begin_x = 400; + + begin_x = start.create(scn, begin_x); + + begin_x = hallway.create(scn, begin_x, 1, Color::YELLOW); + + begin_x = forest.create(scn, begin_x, "1"); + + 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 = forest.create(scn, begin_x, "2"); + + begin_x = hallway.create(scn, begin_x, 4, Color::GREEN); + + begin_x = aquarium.create(scn, begin_x); +} diff --git a/game/background/BackgroundSubScene.h b/game/background/BackgroundSubScene.h new file mode 100644 index 0000000..06bdac4 --- /dev/null +++ b/game/background/BackgroundSubScene.h @@ -0,0 +1,10 @@ +#pragma once + +namespace crepe { +class Scene; +} + +class BackgroundSubScene { +public: + BackgroundSubScene(crepe::Scene & scn); +}; diff --git a/game/background/ForestParallaxScript.cpp b/game/background/ForestParallaxScript.cpp new file mode 100644 index 0000000..27e30eb --- /dev/null +++ b/game/background/ForestParallaxScript.cpp @@ -0,0 +1,28 @@ +#include "ForestParallaxScript.h" + +using namespace crepe; +using namespace std; + +ForestParallaxScript::ForestParallaxScript(float begin_x, float end_x, + std::string unique_bg_name) + : begin_x(begin_x), + end_x(end_x), + name(unique_bg_name) {} + +void ForestParallaxScript::fixed_update(crepe::duration_t dt) { + RefVector vec_2 + = this->get_components_by_name("forest_bg_2_" + name); + RefVector vec_3 + = this->get_components_by_name("forest_bg_3_" + name); + + for (Transform & t : vec_2) { + if (t.position.x > end_x - 400) { + t.position.x = begin_x - 400; + } + } + for (Transform & t : vec_3) { + if (t.position.x > end_x - 400) { + t.position.x = begin_x - 400; + } + } +} diff --git a/game/background/ForestParallaxScript.h b/game/background/ForestParallaxScript.h new file mode 100644 index 0000000..a65a684 --- /dev/null +++ b/game/background/ForestParallaxScript.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +class ForestParallaxScript : public crepe::Script { +public: + ForestParallaxScript(float begin_x, float end_x, std::string unique_bg_name); + + void fixed_update(crepe::duration_t dt); + +private: + const float begin_x; + const float end_x; + const std::string name; +}; diff --git a/game/background/ForestSubScene.cpp b/game/background/ForestSubScene.cpp new file mode 100644 index 0000000..810ef17 --- /dev/null +++ b/game/background/ForestSubScene.cpp @@ -0,0 +1,131 @@ +#include "ForestSubScene.h" +#include "ForestParallaxScript.h" + +#include +#include +#include +#include +#include +#include +#include + +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"); + 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)); + Asset begin_asset{"asset/background/forest/forestFG_1_TVOS.png"}; + begin.add_component(begin_asset, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 0, + .size = vec2(0, 800), + }); + begin_x += 800; + + this->add_background(scn, begin_x, unique_bg_name); + + GameObject middle_1 = scn.new_object("forest_middle", "background", vec2(begin_x, 0)); + Asset middle_1_asset{"asset/background/forest/forestFG_3_TVOS.png"}; + middle_1.add_component(middle_1_asset, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 2, + .size = vec2(0, 800), + }); + begin_x += 800; + + this->add_background(scn, begin_x, unique_bg_name); + + GameObject middle_2 = scn.new_object("forest_middle", "background", vec2(begin_x, 0)); + Asset middle_2_asset{"asset/background/forest/forestFG_3_TVOS.png"}; + middle_2.add_component(middle_2_asset, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 3, + .size = vec2(0, 800), + }); + begin_x += 800; + + this->add_background(scn, begin_x, unique_bg_name); + + GameObject end = scn.new_object("forest_end", "background", vec2(begin_x, 0)); + Asset end_asset{"asset/background/forest/forestFG_2_TVOS.png"}; + end.add_component(end_asset, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 1, + .size = vec2(0, 800), + }); + begin_x += 600; + + this->add_background(scn, begin_x + 200, unique_bg_name); + + return begin_x; +} + +void ForestSubScene::add_background(Scene & scn, float begin_x, std::string name) { + GameObject bg_1 + = scn.new_object("forest_bg_1_" + name, "forest_background", vec2(begin_x, 0)); + Asset bg_1_asset{"asset/background/forest/forestBG1_1_TVOS.png"}; + bg_1.add_component(bg_1_asset, Sprite::Data{ + .sorting_in_layer = 3, + .order_in_layer = 2, + .size = vec2(0, 800), + }); + GameObject bg_2 + = scn.new_object("forest_bg_2_" + name, "forest_background", vec2(begin_x, 0)); + Asset bg_2_1_asset{"asset/background/forest/forestBG2_1_TVOS.png"}; + bg_2.add_component(bg_2_1_asset, Sprite::Data{ + .sorting_in_layer = 3, + .order_in_layer = 1, + .size = vec2(0, 400), + .position_offset = vec2(200, 0), + }); + Asset bg_2_2_asset{"asset/background/forest/forestBG2_2_TVOS.png"}; + bg_2.add_component(bg_2_2_asset, Sprite::Data{ + .sorting_in_layer = 3, + .order_in_layer = 1, + .size = vec2(0, 400), + .position_offset = vec2(-200, 0), + }); + GameObject bg_3 + = scn.new_object("forest_bg_3_" + name, "forest_background", vec2(begin_x, 0)); + Asset bg_3_1_asset{"asset/background/forest/forestBG3_1_TVOS.png"}; + bg_3.add_component(bg_3_1_asset, Sprite::Data{ + .sorting_in_layer = 3, + .order_in_layer = 0, + .size = vec2(0, 200), + .position_offset = vec2(300, 0), + }); + Asset bg_3_2_asset{"asset/background/forest/forestBG3_2_TVOS.png"}; + bg_3.add_component(bg_3_2_asset, Sprite::Data{ + .sorting_in_layer = 3, + .order_in_layer = 0, + .size = vec2(0, 200), + .position_offset = vec2(100, 0), + }); + Asset bg_3_3_asset{"asset/background/forest/forestBG3_3_TVOS.png"}; + bg_3.add_component(bg_3_3_asset, Sprite::Data{ + .sorting_in_layer = 3, + .order_in_layer = 0, + .size = vec2(0, 200), + .position_offset = vec2(-100, 0), + }); + Asset bg_3_4_asset{"asset/background/forest/forestBG3_4_TVOS.png"}; + bg_3.add_component(bg_3_4_asset, Sprite::Data{ + .sorting_in_layer = 3, + .order_in_layer = 0, + .size = vec2(0, 200), + .position_offset = vec2(-300, 0), + }); + + bg_2.add_component(Rigidbody::Data{ + .linear_velocity = vec2(30, 0), + }); + bg_3.add_component(Rigidbody::Data{ + .linear_velocity = vec2(40, 0), + }); +} diff --git a/game/background/ForestSubScene.h b/game/background/ForestSubScene.h new file mode 100644 index 0000000..0a04001 --- /dev/null +++ b/game/background/ForestSubScene.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace crepe { +class Scene; +} + +class ForestSubScene { +public: + float create(crepe::Scene & scn, float begin_x, std::string unique_bg_name); + +private: + void add_background(crepe::Scene & scn, float begin_x, std::string name); +}; diff --git a/game/background/HallwaySubScene.cpp b/game/background/HallwaySubScene.cpp new file mode 100644 index 0000000..486b8c6 --- /dev/null +++ b/game/background/HallwaySubScene.cpp @@ -0,0 +1,128 @@ +#include "HallwaySubScene.h" + +#include +#include +#include +#include +#include + +using namespace crepe; +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)); + Asset begin_asset{"asset/background/hallway/hallway1FG_1_TVOS.png"}; + begin.add_component(begin_asset, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 0, + .size = vec2(0, 800), + }); + begin_x += 600; + + this->add_sector_number(begin, vec2(-200, 0), sector_num, sector_color); + 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)); + Asset middle_asset{"asset/background/hallway/hallway1FG_2_TVOS.png"}; + middle_1.add_component(middle_asset, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 2, + .size = vec2(0, 800), + }); + begin_x += 600; + + GameObject middle_2 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); + Asset middle_asset_2{"asset/background/hallway/hallway1FG_2_TVOS.png"}; + middle_2.add_component(middle_asset_2, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 3, + .size = vec2(0, 800), + }); + begin_x += 200; + + GameObject middle_3 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); + Asset middle_asset_3{"asset/background/hallway/hallway1FG_2_TVOS.png"}; + middle_3.add_component(middle_asset_3, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 4, + .size = vec2(0, 800), + }); + begin_x += 400; + + this->add_lamp(middle_3, vec2(0, -120)); + + GameObject middle_4 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); + Asset middle_asset_4{"asset/background/hallway/hallway1FG_2_TVOS.png"}; + middle_4.add_component(middle_asset_4, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 5, + .size = vec2(0, 800), + }); + begin_x += 600; + + GameObject end = scn.new_object("hallway_end", "background", vec2(begin_x, 0)); + Asset end_asset{"asset/background/hallway/hallway1FG_1_TVOS.png"}; + end.add_component(end_asset, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 1, + .size = vec2(0, 800), + }); + begin_x += 600; + + return begin_x; +} + +void HallwaySubScene::add_lamp(GameObject & obj, vec2 offset, unsigned int fps) { + Asset lamp_asset{"asset/background/hallway/alarmLight_TVOS.png"}; + obj.add_component(lamp_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 0, + .size = vec2(0, 100), + .position_offset = offset, + }); + Asset lamp_glow_asset{"asset/background/hallway/alarmGlow_TVOS.png"}; + Sprite & lamp_glow_sprite = obj.add_component( + lamp_glow_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 1, + .size = vec2(0, 300), + .position_offset = offset - vec2(65, -30), + }); + obj.add_component(lamp_glow_sprite, ivec2(422, 384), uvec2(6, 1), + Animator::Data{ + .fps = fps, + .looping = true, + }); +} + +void HallwaySubScene::add_sector_number(GameObject & obj, vec2 offset, unsigned int sector_num, + Color sector_color) { + Asset sector_text_asset{"asset/background/hallway/sectorText_TVOS.png"}; + obj.add_component(sector_text_asset, Sprite::Data{ + .color = sector_color, + .sorting_in_layer = 5, + .order_in_layer = 0, + .size = vec2(0, 100), + .position_offset = offset, + }); + Asset sector_num_asset{"asset/background/hallway/sectorNumbers_TVOS.png"}; + Sprite & sector_num_sprite = obj.add_component( + sector_num_asset, Sprite::Data{ + .color = sector_color, + .sorting_in_layer = 5, + .order_in_layer = 0, + .size = vec2(0, 100), + .position_offset = offset + vec2(200, 0), + }); + Animator & sector_num_anim = obj.add_component( + sector_num_sprite, ivec2(256, 128), uvec2(4, 4), Animator::Data{}); + int column = (sector_num - 1) / 4; + int row = (sector_num - 1) % 4; + sector_num_anim.set_anim(column); + for (int i = 0; i < row; i++) { + sector_num_anim.next_anim(); + } + sector_num_anim.pause(); +} diff --git a/game/background/HallwaySubScene.h b/game/background/HallwaySubScene.h new file mode 100644 index 0000000..acc9329 --- /dev/null +++ b/game/background/HallwaySubScene.h @@ -0,0 +1,21 @@ +#pragma once + +#include + +namespace crepe { +class Scene; +class GameObject; +class Color; +} // namespace crepe + +class HallwaySubScene { +public: + float create(crepe::Scene & scn, float begin_x, unsigned int sector_num, + crepe::Color sector_color); + +private: + void add_lamp(crepe::GameObject & obj, crepe::vec2 offset, unsigned int fps = 10); + + void add_sector_number(crepe::GameObject & obj, crepe::vec2 offset, + unsigned int sector_num, crepe::Color sector_color); +}; diff --git a/game/background/StartSubScene.cpp b/game/background/StartSubScene.cpp new file mode 100644 index 0000000..5d810c2 --- /dev/null +++ b/game/background/StartSubScene.cpp @@ -0,0 +1,442 @@ +#include "StartSubScene.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace crepe; +using namespace std; + +float StartSubScene::create(Scene & scn, float begin_x) { + this->create_wall_fragments(scn, begin_x - 300); + + GameObject begin = scn.new_object("start_begin", "background", vec2(begin_x, 0)); + Asset begin_asset{"asset/background/start/titleFG_1_TVOS.png"}; + begin.add_component(begin_asset, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 0, + .size = vec2(0, 800), + }); + GameObject hole = scn.new_object("start_hole", "background", vec2(begin_x - 250, 140)); + Asset hole_asset{"asset/background/start/titleWallHole.png"}; + Sprite & hole_sprite = hole.add_component(hole_asset, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 1, + .size = vec2(0, 200), + }); + hole_sprite.active = false; + begin_x += 700; + + this->add_table(begin, vec2(-150, 150)); + this->add_light(begin, vec2(-125, -150)); + this->add_jetpack_stand(begin, vec2(-125, 200)); + + GameObject end = scn.new_object("start_end", "background", vec2(begin_x, 0)); + Asset end_asset{"asset/background/start/titleFG_2_TVOS.png"}; + end.add_component(end_asset, Sprite::Data{ + .sorting_in_layer = 4, + .order_in_layer = 1, + .size = vec2(0, 800), + }); + begin_x += 100; + + this->add_lamp(end, vec2(-350, -95)); + + return begin_x; +} + +void StartSubScene::add_lamp(GameObject & obj, vec2 offset, unsigned int fps) { + Asset lamp_asset{"asset/background/start/alarmLight_TVOS.png"}; + obj.add_component(lamp_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 0, + .size = vec2(0, 100), + .position_offset = offset, + }); + Asset lamp_glow_asset{"asset/background/start/alarmGlow_TVOS.png"}; + Sprite & lamp_glow_sprite = obj.add_component( + lamp_glow_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 1, + .size = vec2(0, 300), + .position_offset = offset - vec2(65, -55), + }); + lamp_glow_sprite.active = false; + obj.add_component(lamp_glow_sprite, ivec2(422, 384), uvec2(6, 1), + Animator::Data{ + .fps = fps, + .looping = true, + }); +} + +void StartSubScene::add_table(GameObject & obj, vec2 offset) { + Asset table_asset{"asset/background/start/table.png"}; + obj.add_component(table_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 0, + .size = vec2(0, 100), + .position_offset = offset, + }); + Asset gramophone_asset{"asset/background/start/gramophone_TVOS.png"}; + Sprite & gramophone_sprite = obj.add_component( + gramophone_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 1, + .size = vec2(0, 100), + .position_offset = offset + vec2(0, -50), + }); + obj.add_component(gramophone_sprite, ivec2(64, 128), uvec2(2, 1), + Animator::Data{ + .fps = 10, + .looping = true, + }); +} + +void StartSubScene::add_light(crepe::GameObject & obj, crepe::vec2 offset) { + Asset light_asset{"asset/background/start/title_light_TVOS.png"}; + obj.add_component(light_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 0, + .size = vec2(0, 200), + .position_offset = offset, + }); + Asset light_glow_asset{"asset/background/start/lightEffect2.png"}; + obj.add_component(light_glow_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 1, + .size = vec2(0, 100), + .position_offset = offset + vec2(0, 75), + }); + Asset light_effect_asset{"asset/background/start/lightEffect.png"}; + obj.add_component(light_effect_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 0, + .size = vec2(0, 100), + .position_offset = offset + vec2(0, 350), + }); +} + +void StartSubScene::add_jetpack_stand(crepe::GameObject & obj, crepe::vec2 offset) { + Asset jetpack_stand_asset{"asset/background/start/JetpackStand.png"}; + Sprite & jetpeck_stand_sprite + = obj.add_component(jetpack_stand_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 1, + .size = vec2(0, 70), + .position_offset = offset, + }); + obj.add_component(jetpeck_stand_sprite, ivec2(34, 46), uvec2(2, 1), + Animator::Data{ + .fps = 10, + .looping = true, + }) + .pause(); + Asset do_not_steal = {"asset/background/start/doNotTouchSign_TVOS.png"}; + obj.add_component(do_not_steal, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 1, + .size = vec2(0, 100), + .position_offset = offset + vec2(-75, -25), + }); +} + +void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { + GameObject frag_1 = scn.new_object("frag_1", "wall_fragment", vec2(begin_x, 200)); + Asset frag_1_asset{"asset/background/start/StartWall_frag1.png"}; + Sprite & frag_1_sprite + = frag_1.add_component(frag_1_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 5, + .size = vec2(0, 50), + }); + frag_1_sprite.active = false; + Rigidbody & frag_1_rb = frag_1.add_component(Rigidbody::Data{ + .gravity_scale = 10, + .linear_velocity = vec2(400, 400), + .linear_velocity_coefficient = vec2(0.5, 0.6), + .angular_velocity = 500, + .angular_velocity_coefficient = 0.55, + .elasticity_coefficient = 0.5, + .collision_layer = 5, + }); + frag_1_rb.active = false; + frag_1.add_component(25); + + GameObject frag_2 = scn.new_object("frag_2", "wall_fragment", vec2(begin_x, 180)); + Asset frag_2_asset{"asset/background/start/StartWall_frag2.png"}; + Sprite & frag_2_sprite + = frag_2.add_component(frag_2_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 5, + .size = vec2(0, 50), + }); + frag_2_sprite.active = false; + Rigidbody & frag_2_rb = frag_2.add_component(Rigidbody::Data{ + .gravity_scale = 20, + .linear_velocity = vec2(400, 400), + .linear_velocity_coefficient = vec2(0.35, 0.4), + .angular_velocity = 400, + .angular_velocity_coefficient = 0.55, + .elasticity_coefficient = 0.5, + .collision_layer = 5, + }); + frag_2_rb.active = false; + frag_2.add_component(55); + + GameObject frag_3 = scn.new_object("frag_3", "wall_fragment", vec2(begin_x, 170)); + Asset frag_3_asset{"asset/background/start/StartWall_frag3.png"}; + Sprite & frag_3_sprite + = frag_3.add_component(frag_3_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 5, + .size = vec2(0, 50), + }); + frag_3_sprite.active = false; + Rigidbody & frag_3_rb = frag_3.add_component(Rigidbody::Data{ + .gravity_scale = 30, + .linear_velocity = vec2(400, 400), + .linear_velocity_coefficient = vec2(0.3, 0.3), + .angular_velocity = 300, + .angular_velocity_coefficient = 0.55, + .elasticity_coefficient = 0.5, + .collision_layer = 5, + }); + frag_3_rb.active = false; + frag_3.add_component(35); + + GameObject frag_4 = scn.new_object("frag_4", "wall_fragment", vec2(begin_x, 160)); + Asset frag_4_asset{"asset/background/start/StartWall_frag4.png"}; + Sprite & frag_4_sprite + = frag_4.add_component(frag_4_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 5, + .size = vec2(0, 50), + }); + frag_4_sprite.active = false; + Rigidbody & frag_4_rb = frag_4.add_component(Rigidbody::Data{ + .gravity_scale = 40, + .linear_velocity = vec2(700, 400), + .linear_velocity_coefficient = vec2(0.2, 0.2), + .angular_velocity = 200, + .angular_velocity_coefficient = 0.55, + .elasticity_coefficient = 0.5, + .collision_layer = 5, + }); + frag_4_rb.active = false; + frag_4.add_component(60); + + GameObject frag_5 = scn.new_object("frag_5", "wall_fragment", vec2(begin_x, 150)); + Asset frag_5_asset{"asset/background/start/StartWall_frag5.png"}; + Sprite & frag_5_sprite + = frag_5.add_component(frag_5_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 5, + .size = vec2(0, 50), + }); + frag_5_sprite.active = false; + Rigidbody & frag_5_rb = frag_5.add_component(Rigidbody::Data{ + .gravity_scale = 50, + .linear_velocity = vec2(600, 800), + .linear_velocity_coefficient = vec2(0.25, 0.15), + .angular_velocity = 100, + .angular_velocity_coefficient = 0.55, + .elasticity_coefficient = 0.5, + .collision_layer = 5, + }); + frag_5_rb.active = false; + frag_5.add_component(5); + + GameObject frag_6 = scn.new_object("frag_6", "wall_fragment", vec2(begin_x, 140)); + Asset frag_6_asset{"asset/background/start/StartWall_frag6.png"}; + Sprite & frag_6_sprite + = frag_6.add_component(frag_6_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 5, + .size = vec2(0, 50), + }); + frag_6_sprite.active = false; + Rigidbody & frag_6_rb = frag_6.add_component(Rigidbody::Data{ + .gravity_scale = 30, + .linear_velocity = vec2(300, 800), + .linear_velocity_coefficient = vec2(0.35, 0.25), + .angular_velocity = 100, + .angular_velocity_coefficient = 0.55, + .elasticity_coefficient = 0.5, + .collision_layer = 5, + }); + frag_6_rb.active = false; + frag_6.add_component(30); + + GameObject frag_7 = scn.new_object("frag_7", "wall_fragment", vec2(begin_x, 130)); + Asset frag_7_asset{"asset/background/start/StartWall_frag7.png"}; + Sprite & frag_7_sprite + = frag_7.add_component(frag_7_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 5, + .size = vec2(0, 50), + }); + frag_7_sprite.active = false; + Rigidbody & frag_7_rb = frag_7.add_component(Rigidbody::Data{ + .gravity_scale = 20, + .linear_velocity = vec2(400, 500), + .linear_velocity_coefficient = vec2(0.45, 0.6), + .angular_velocity = 800, + .angular_velocity_coefficient = 0.55, + .elasticity_coefficient = 0.5, + .collision_layer = 5, + }); + frag_7_rb.active = false; + frag_7.add_component(45); + + GameObject frag_8 = scn.new_object("frag_8", "wall_fragment", vec2(begin_x, 120)); + Asset frag_8_asset{"asset/background/start/StartWall_frag8.png"}; + Sprite & frag_8_sprite + = frag_8.add_component(frag_8_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 5, + .size = vec2(0, 50), + }); + frag_8_sprite.active = false; + Rigidbody & frag_8_rb = frag_8.add_component(Rigidbody::Data{ + .gravity_scale = 30, + .linear_velocity = vec2(400, 400), + .linear_velocity_coefficient = vec2(0.5, 0.6), + .angular_velocity = 500, + .angular_velocity_coefficient = 0.55, + .elasticity_coefficient = 0.5, + .collision_layer = 5, + }); + frag_8_rb.active = false; + frag_8.add_component(25); + + GameObject frag_9 = scn.new_object("frag_9", "wall_fragment", vec2(begin_x, 110)); + Asset frag_9_asset{"asset/background/start/StartWall_frag9.png"}; + Sprite & frag_9_sprite + = frag_9.add_component(frag_9_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 5, + .size = vec2(0, 50), + }); + frag_9_sprite.active = false; + Rigidbody & frag_9_rb = frag_9.add_component(Rigidbody::Data{ + .gravity_scale = 40, + .linear_velocity = vec2(200, 400), + .linear_velocity_coefficient = vec2(0.5, 0.25), + .angular_velocity = 500, + .angular_velocity_coefficient = 0.55, + .elasticity_coefficient = 0.5, + .collision_layer = 5, + }); + frag_9_rb.active = false; + frag_9.add_component(15); + + GameObject frag_10 = scn.new_object("frag_10", "wall_fragment", vec2(begin_x, 100)); + Asset frag_10_asset{"asset/background/start/StartWall_frag10.png"}; + Sprite & frag_10_sprite + = frag_10.add_component(frag_10_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 5, + .size = vec2(0, 50), + }); + frag_10_sprite.active = false; + Rigidbody & frag_10_rb = frag_10.add_component(Rigidbody::Data{ + .gravity_scale = 50, + .linear_velocity = vec2(400, 900), + .linear_velocity_coefficient = vec2(0.35, 0.4), + .angular_velocity = 300, + .angular_velocity_coefficient = 0.55, + .elasticity_coefficient = 0.5, + .collision_layer = 5, + }); + frag_10_rb.active = false; + frag_10.add_component(60); + + GameObject frag_11 = scn.new_object("frag_11", "wall_fragment", vec2(begin_x, 90)); + Asset frag_11_asset{"asset/background/start/StartWall_frag11.png"}; + Sprite & frag_11_sprite + = frag_11.add_component(frag_11_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 5, + .size = vec2(0, 50), + }); + frag_11_sprite.active = false; + Rigidbody & frag_11_rb = frag_11.add_component(Rigidbody::Data{ + .gravity_scale = 60, + .linear_velocity = vec2(600, 800), + .linear_velocity_coefficient = vec2(0.3, 0.3), + .angular_velocity = 200, + .angular_velocity_coefficient = 0.55, + .elasticity_coefficient = 0.5, + .collision_layer = 5, + }); + frag_11_rb.active = false; + frag_11.add_component(5); + + GameObject frag_12 = scn.new_object("frag_12", "wall_fragment", vec2(begin_x, 80)); + Asset frag_12_asset{"asset/background/start/StartWall_frag12.png"}; + Sprite & frag_12_sprite + = frag_12.add_component(frag_12_asset, Sprite::Data{ + .sorting_in_layer = 5, + .order_in_layer = 5, + .size = vec2(0, 50), + }); + frag_12_sprite.active = false; + Rigidbody & frag_12_rb = frag_12.add_component(Rigidbody::Data{ + .gravity_scale = 70, + .linear_velocity = vec2(500, 800), + .linear_velocity_coefficient = vec2(0.25, 0.15), + .angular_velocity = 100, + .angular_velocity_coefficient = 0.55, + .elasticity_coefficient = 0.5, + .collision_layer = 5, + }); + frag_12_rb.active = false; + frag_12.add_component(50); + + GameObject smoke_particles_1 + = scn.new_object("smoke_particles", "particle_emitter", vec2(begin_x - 100, 200)); + Asset smoke_asset_1{"asset/particles/smoke.png"}; + Sprite & smoke_sprite_1 = smoke_particles_1.add_component( + smoke_asset_1, Sprite::Data{ + .color = Color(255, 255, 255, 50), + .sorting_in_layer = 15, + .order_in_layer = 0, + .size = vec2(0, 100), + }); + ParticleEmitter & emitter_1 = smoke_particles_1.add_component( + smoke_sprite_1, ParticleEmitter::Data{ + .emission_rate = 20, + .min_speed = 40, + .max_speed = 100, + .min_angle = -30, + .max_angle = 10, + .end_lifespan = 4, + }); + emitter_1.active = false; + + GameObject smoke_particles_2 + = scn.new_object("smoke_particles", "particle_emitter", vec2(begin_x - 100, 200)); + Asset smoke_asset_2{"asset/particles/smoke.png"}; + Sprite & smoke_sprite_2 = smoke_particles_2.add_component( + smoke_asset_2, Sprite::Data{ + .color = Color(255, 255, 255, 50), + .sorting_in_layer = 15, + .order_in_layer = 0, + .size = vec2(0, 70), + }); + ParticleEmitter & emitter_2 = smoke_particles_2.add_component( + smoke_sprite_2, ParticleEmitter::Data{ + .emission_rate = 30, + .min_speed = 40, + .max_speed = 100, + .min_angle = -45, + .max_angle = 5, + .end_lifespan = 3, + }); + emitter_2.active = false; +} diff --git a/game/background/StartSubScene.h b/game/background/StartSubScene.h new file mode 100644 index 0000000..c83e3d5 --- /dev/null +++ b/game/background/StartSubScene.h @@ -0,0 +1,20 @@ +#pragma once + +#include + +namespace crepe { +class Scene; +class GameObject; +} // namespace crepe + +class StartSubScene { +public: + float create(crepe::Scene & scn, float begin_x); + +private: + void add_lamp(crepe::GameObject & obj, crepe::vec2 offset, unsigned int fps = 10); + void add_table(crepe::GameObject & obj, crepe::vec2 offset); + void add_light(crepe::GameObject & obj, crepe::vec2 offset); + void add_jetpack_stand(crepe::GameObject & obj, crepe::vec2 offset); + void create_wall_fragments(crepe::Scene & scn, float begin_x); +}; -- cgit v1.2.3 From d2af158ac63ab05b2fbfdcdf1b483662e48c0544 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Sat, 21 Dec 2024 11:36:37 +0100 Subject: Added Config.h --- game/Config.h | 11 ++ game/PlayerSubScene.cpp | 29 ++--- game/background/AquariumSubScene.cpp | 146 ++++++++++++---------- game/background/ForestSubScene.cpp | 108 +++++++++-------- game/background/HallwaySubScene.cpp | 71 ++++++----- game/background/StartSubScene.cpp | 228 ++++++++++++++++++----------------- mwe/events/include/event.h | 2 +- src/crepe/system/InputSystem.h | 6 +- 8 files changed, 325 insertions(+), 276 deletions(-) create mode 100644 game/Config.h (limited to 'game') diff --git a/game/Config.h b/game/Config.h new file mode 100644 index 0000000..7a83ee6 --- /dev/null +++ b/game/Config.h @@ -0,0 +1,11 @@ +#pragma once + +static constexpr int SORT_IN_LAY_BACK_BACKGROUND = 3; +static constexpr int SORT_IN_LAY_BACKGROUND = 4; +static constexpr int SORT_IN_LAY_FORE_BACKGROUND = 5; +static constexpr int SORT_IN_LAY_PARTICLES_BACKGROUND = 6; +static constexpr int SORT_IN_LAY_OBSTACLES = 8; +static constexpr int SORT_IN_LAY_PLAYER = 10; +static constexpr int SORT_IN_LAY_PARTICLES_FOREGROUND = 15; + + diff --git a/game/PlayerSubScene.cpp b/game/PlayerSubScene.cpp index 01a383a..d81dd34 100644 --- a/game/PlayerSubScene.cpp +++ b/game/PlayerSubScene.cpp @@ -1,4 +1,5 @@ #include "PlayerSubScene.h" +#include "Config.h" #include "PlayerScript.h" #include @@ -13,25 +14,25 @@ using namespace std; PlayerSubScene::PlayerSubScene(Scene & scn) { GameObject player = scn.new_object("player", "player", vec2(-100, 200)); Asset player_body_asset{"asset/barry/defaultBody.png"}; - Sprite & player_body_sprite - = player.add_component(player_body_asset, Sprite::Data{ - .sorting_in_layer = 10, - .order_in_layer = 0, - .size = vec2(0, 50), - }); + Sprite & player_body_sprite = player.add_component( + player_body_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_PLAYER, + .order_in_layer = 0, + .size = vec2(0, 50), + }); player.add_component(player_body_sprite, ivec2(32, 32), uvec2(4, 8), Animator::Data{ .fps = 5, .looping = true, }); Asset player_head_asset{"asset/barry/defaultHead.png"}; - Sprite & player_head_sprite - = player.add_component(player_head_asset, Sprite::Data{ - .sorting_in_layer = 10, - .order_in_layer = 1, - .size = vec2(0, 50), - .position_offset = vec2(0, -20), - }); + Sprite & player_head_sprite = player.add_component( + player_head_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_PLAYER, + .order_in_layer = 1, + .size = vec2(0, 50), + .position_offset = vec2(0, -20), + }); player.add_component(player_head_sprite, ivec2(32, 32), uvec2(4, 8), Animator::Data{ .fps = 5, @@ -40,7 +41,7 @@ PlayerSubScene::PlayerSubScene(Scene & scn) { Asset player_jetpack_asset{"asset/barry/jetpackDefault.png"}; Sprite & player_jetpack_sprite = player.add_component( player_jetpack_asset, Sprite::Data{ - .sorting_in_layer = 10, + .sorting_in_layer = SORT_IN_LAY_PLAYER, .order_in_layer = 2, .size = vec2(0, 60), .position_offset = vec2(-20, 0), diff --git a/game/background/AquariumSubScene.cpp b/game/background/AquariumSubScene.cpp index 40e22b7..9994a9e 100644 --- a/game/background/AquariumSubScene.cpp +++ b/game/background/AquariumSubScene.cpp @@ -1,5 +1,7 @@ #include "AquariumSubScene.h" +#include "../Config.h" + #include #include #include @@ -15,21 +17,23 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { GameObject aquarium_begin = scn.new_object("aquarium_begin", "background", vec2(begin_x, 0)); Asset aquarium_begin_asset{"asset/background/aquarium/glassTubeFG_1_TVOS.png"}; - aquarium_begin.add_component(aquarium_begin_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 0, - .size = vec2(0, 800), - }); + aquarium_begin.add_component(aquarium_begin_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, + .order_in_layer = 0, + .size = vec2(0, 800), + }); begin_x += 600; GameObject aquarium_middle_1 = scn.new_object("aquarium_middle", "background", 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, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 2, - .size = vec2(0, 800), - }); + aquarium_middle_1.add_component(aquarium_middle_1_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, + .order_in_layer = 2, + .size = vec2(0, 800), + }); begin_x += 400; this->add_background(scn, begin_x - 200); @@ -37,21 +41,23 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { GameObject aquarium_middle_2 = scn.new_object("aquarium_middle", "background", 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, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 3, - .size = vec2(0, 800), - }); + aquarium_middle_2.add_component(aquarium_middle_2_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, + .order_in_layer = 3, + .size = vec2(0, 800), + }); begin_x += 400; GameObject aquarium_middle_3 = scn.new_object("aquarium_middle", "background", 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, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 4, - .size = vec2(0, 800), - }); + aquarium_middle_3.add_component(aquarium_middle_3_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, + .order_in_layer = 4, + .size = vec2(0, 800), + }); begin_x += 400; this->add_background(scn, begin_x - 200); @@ -59,22 +65,24 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { GameObject aquarium_middle_4 = scn.new_object("aquarium_middle", "background", 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, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 5, - .size = vec2(0, 800), - }); + aquarium_middle_4.add_component(aquarium_middle_4_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 800), + }); begin_x += 600; this->add_background(scn, begin_x); GameObject aquarium_end = scn.new_object("aquarium_end", "background", vec2(begin_x, 0)); Asset aquarium_end_asset{"asset/background/aquarium/glassTubeFG_2_TVOS.png"}; - aquarium_end.add_component(aquarium_end_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 1, - .size = vec2(0, 800), - }); + aquarium_end.add_component(aquarium_end_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, + .order_in_layer = 1, + .size = vec2(0, 800), + }); begin_x += 600; return begin_x; @@ -83,47 +91,53 @@ 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)); Asset bg_1_1_asset{"asset/background/aquarium/AquariumBG1_1_TVOS.png"}; - bg_1.add_component(bg_1_1_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 2, - .size = vec2(0, 400), - .position_offset = vec2(-200, 100), - }); + bg_1.add_component(bg_1_1_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACK_BACKGROUND, + .order_in_layer = 2, + .size = vec2(0, 400), + .position_offset = vec2(-200, 100), + }); Asset bg_1_2_asset{"asset/background/aquarium/AquariumBG1_2_TVOS.png"}; - bg_1.add_component(bg_1_2_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 2, - .size = vec2(0, 400), - .position_offset = vec2(200, 100), - }); + bg_1.add_component(bg_1_2_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACK_BACKGROUND, + .order_in_layer = 2, + .size = vec2(0, 400), + .position_offset = vec2(200, 100), + }); GameObject bg_2 = scn.new_object("aquarium_bg_2", "aquarium_background", vec2(begin_x, 0)); Asset bg_2_1_asset{"asset/background/aquarium/AquariumBG2_1_TVOS.png"}; - bg_2.add_component(bg_2_1_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 1, - .size = vec2(0, 400), - .position_offset = vec2(200, -50), - }); + bg_2.add_component(bg_2_1_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACK_BACKGROUND, + .order_in_layer = 1, + .size = vec2(0, 400), + .position_offset = vec2(200, -50), + }); Asset bg_2_2_asset{"asset/background/aquarium/AquariumBG2_2_TVOS.png"}; - bg_2.add_component(bg_2_2_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 1, - .size = vec2(0, 400), - .position_offset = vec2(-200, -50), - }); + bg_2.add_component(bg_2_2_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACK_BACKGROUND, + .order_in_layer = 1, + .size = vec2(0, 400), + .position_offset = vec2(-200, -50), + }); GameObject bg_3 = scn.new_object("aquarium_bg_3", "aquarium_background", vec2(begin_x, 0)); Asset bg_3_1_asset{"asset/background/aquarium/AquariumBG3_1_TVOS.png"}; - bg_3.add_component(bg_3_1_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 0, - .size = vec2(0, 400), - .position_offset = vec2(200, -200), - }); + bg_3.add_component(bg_3_1_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACK_BACKGROUND, + .order_in_layer = 0, + .size = vec2(0, 400), + .position_offset = vec2(200, -200), + }); Asset bg_3_2_asset{"asset/background/aquarium/AquariumBG3_2_TVOS.png"}; - bg_3.add_component(bg_3_2_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 0, - .size = vec2(0, 400), - .position_offset = vec2(-200, -200), - }); + bg_3.add_component(bg_3_2_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACK_BACKGROUND, + .order_in_layer = 0, + .size = vec2(0, 400), + .position_offset = vec2(-200, -200), + }); } diff --git a/game/background/ForestSubScene.cpp b/game/background/ForestSubScene.cpp index 810ef17..f0848f2 100644 --- a/game/background/ForestSubScene.cpp +++ b/game/background/ForestSubScene.cpp @@ -1,6 +1,8 @@ #include "ForestSubScene.h" #include "ForestParallaxScript.h" +#include "../Config.h" + #include #include #include @@ -22,7 +24,7 @@ float ForestSubScene::create(Scene & scn, float begin_x, std::string unique_bg_n GameObject begin = scn.new_object("forest_begin", "background", vec2(begin_x, 0)); Asset begin_asset{"asset/background/forest/forestFG_1_TVOS.png"}; begin.add_component(begin_asset, Sprite::Data{ - .sorting_in_layer = 4, + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 0, .size = vec2(0, 800), }); @@ -32,22 +34,24 @@ float ForestSubScene::create(Scene & scn, float begin_x, std::string unique_bg_n GameObject middle_1 = scn.new_object("forest_middle", "background", vec2(begin_x, 0)); Asset middle_1_asset{"asset/background/forest/forestFG_3_TVOS.png"}; - middle_1.add_component(middle_1_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 2, - .size = vec2(0, 800), - }); + middle_1.add_component(middle_1_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, + .order_in_layer = 2, + .size = vec2(0, 800), + }); begin_x += 800; this->add_background(scn, begin_x, unique_bg_name); GameObject middle_2 = scn.new_object("forest_middle", "background", vec2(begin_x, 0)); Asset middle_2_asset{"asset/background/forest/forestFG_3_TVOS.png"}; - middle_2.add_component(middle_2_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 3, - .size = vec2(0, 800), - }); + middle_2.add_component(middle_2_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, + .order_in_layer = 3, + .size = vec2(0, 800), + }); begin_x += 800; this->add_background(scn, begin_x, unique_bg_name); @@ -55,7 +59,7 @@ float ForestSubScene::create(Scene & scn, float begin_x, std::string unique_bg_n GameObject end = scn.new_object("forest_end", "background", vec2(begin_x, 0)); Asset end_asset{"asset/background/forest/forestFG_2_TVOS.png"}; end.add_component(end_asset, Sprite::Data{ - .sorting_in_layer = 4, + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 1, .size = vec2(0, 800), }); @@ -71,56 +75,62 @@ void ForestSubScene::add_background(Scene & scn, float begin_x, std::string name = scn.new_object("forest_bg_1_" + name, "forest_background", vec2(begin_x, 0)); Asset bg_1_asset{"asset/background/forest/forestBG1_1_TVOS.png"}; bg_1.add_component(bg_1_asset, Sprite::Data{ - .sorting_in_layer = 3, + .sorting_in_layer = SORT_IN_LAY_BACK_BACKGROUND, .order_in_layer = 2, .size = vec2(0, 800), }); GameObject bg_2 = scn.new_object("forest_bg_2_" + name, "forest_background", vec2(begin_x, 0)); Asset bg_2_1_asset{"asset/background/forest/forestBG2_1_TVOS.png"}; - bg_2.add_component(bg_2_1_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 1, - .size = vec2(0, 400), - .position_offset = vec2(200, 0), - }); + bg_2.add_component(bg_2_1_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACK_BACKGROUND, + .order_in_layer = 1, + .size = vec2(0, 400), + .position_offset = vec2(200, 0), + }); Asset bg_2_2_asset{"asset/background/forest/forestBG2_2_TVOS.png"}; - bg_2.add_component(bg_2_2_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 1, - .size = vec2(0, 400), - .position_offset = vec2(-200, 0), - }); + bg_2.add_component(bg_2_2_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACK_BACKGROUND, + .order_in_layer = 1, + .size = vec2(0, 400), + .position_offset = vec2(-200, 0), + }); GameObject bg_3 = scn.new_object("forest_bg_3_" + name, "forest_background", vec2(begin_x, 0)); Asset bg_3_1_asset{"asset/background/forest/forestBG3_1_TVOS.png"}; - bg_3.add_component(bg_3_1_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 0, - .size = vec2(0, 200), - .position_offset = vec2(300, 0), - }); + bg_3.add_component(bg_3_1_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACK_BACKGROUND, + .order_in_layer = 0, + .size = vec2(0, 200), + .position_offset = vec2(300, 0), + }); Asset bg_3_2_asset{"asset/background/forest/forestBG3_2_TVOS.png"}; - bg_3.add_component(bg_3_2_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 0, - .size = vec2(0, 200), - .position_offset = vec2(100, 0), - }); + bg_3.add_component(bg_3_2_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACK_BACKGROUND, + .order_in_layer = 0, + .size = vec2(0, 200), + .position_offset = vec2(100, 0), + }); Asset bg_3_3_asset{"asset/background/forest/forestBG3_3_TVOS.png"}; - bg_3.add_component(bg_3_3_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 0, - .size = vec2(0, 200), - .position_offset = vec2(-100, 0), - }); + bg_3.add_component(bg_3_3_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACK_BACKGROUND, + .order_in_layer = 0, + .size = vec2(0, 200), + .position_offset = vec2(-100, 0), + }); Asset bg_3_4_asset{"asset/background/forest/forestBG3_4_TVOS.png"}; - bg_3.add_component(bg_3_4_asset, Sprite::Data{ - .sorting_in_layer = 3, - .order_in_layer = 0, - .size = vec2(0, 200), - .position_offset = vec2(-300, 0), - }); + bg_3.add_component(bg_3_4_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACK_BACKGROUND, + .order_in_layer = 0, + .size = vec2(0, 200), + .position_offset = vec2(-300, 0), + }); bg_2.add_component(Rigidbody::Data{ .linear_velocity = vec2(30, 0), diff --git a/game/background/HallwaySubScene.cpp b/game/background/HallwaySubScene.cpp index 486b8c6..b5e3635 100644 --- a/game/background/HallwaySubScene.cpp +++ b/game/background/HallwaySubScene.cpp @@ -1,5 +1,7 @@ #include "HallwaySubScene.h" +#include "../Config.h" + #include #include #include @@ -14,7 +16,7 @@ float HallwaySubScene::create(Scene & scn, float begin_x, unsigned int sector_nu GameObject begin = scn.new_object("hallway_begin", "background", vec2(begin_x, 0)); Asset begin_asset{"asset/background/hallway/hallway1FG_1_TVOS.png"}; begin.add_component(begin_asset, Sprite::Data{ - .sorting_in_layer = 4, + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 0, .size = vec2(0, 800), }); @@ -26,46 +28,50 @@ float HallwaySubScene::create(Scene & scn, float begin_x, unsigned int sector_nu GameObject middle_1 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); Asset middle_asset{"asset/background/hallway/hallway1FG_2_TVOS.png"}; - middle_1.add_component(middle_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 2, - .size = vec2(0, 800), - }); + middle_1.add_component(middle_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, + .order_in_layer = 2, + .size = vec2(0, 800), + }); begin_x += 600; GameObject middle_2 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); Asset middle_asset_2{"asset/background/hallway/hallway1FG_2_TVOS.png"}; - middle_2.add_component(middle_asset_2, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 3, - .size = vec2(0, 800), - }); + middle_2.add_component(middle_asset_2, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, + .order_in_layer = 3, + .size = vec2(0, 800), + }); begin_x += 200; GameObject middle_3 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); Asset middle_asset_3{"asset/background/hallway/hallway1FG_2_TVOS.png"}; - middle_3.add_component(middle_asset_3, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 4, - .size = vec2(0, 800), - }); + middle_3.add_component(middle_asset_3, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, + .order_in_layer = 4, + .size = vec2(0, 800), + }); begin_x += 400; this->add_lamp(middle_3, vec2(0, -120)); GameObject middle_4 = scn.new_object("hallway_middle", "background", vec2(begin_x, 0)); Asset middle_asset_4{"asset/background/hallway/hallway1FG_2_TVOS.png"}; - middle_4.add_component(middle_asset_4, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 5, - .size = vec2(0, 800), - }); + middle_4.add_component(middle_asset_4, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 800), + }); begin_x += 600; GameObject end = scn.new_object("hallway_end", "background", vec2(begin_x, 0)); Asset end_asset{"asset/background/hallway/hallway1FG_1_TVOS.png"}; end.add_component(end_asset, Sprite::Data{ - .sorting_in_layer = 4, + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 1, .size = vec2(0, 800), }); @@ -77,7 +83,7 @@ float HallwaySubScene::create(Scene & scn, float begin_x, unsigned int sector_nu void HallwaySubScene::add_lamp(GameObject & obj, vec2 offset, unsigned int fps) { Asset lamp_asset{"asset/background/hallway/alarmLight_TVOS.png"}; obj.add_component(lamp_asset, Sprite::Data{ - .sorting_in_layer = 5, + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, .order_in_layer = 0, .size = vec2(0, 100), .position_offset = offset, @@ -85,7 +91,7 @@ void HallwaySubScene::add_lamp(GameObject & obj, vec2 offset, unsigned int fps) Asset lamp_glow_asset{"asset/background/hallway/alarmGlow_TVOS.png"}; Sprite & lamp_glow_sprite = obj.add_component( lamp_glow_asset, Sprite::Data{ - .sorting_in_layer = 5, + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, .order_in_layer = 1, .size = vec2(0, 300), .position_offset = offset - vec2(65, -30), @@ -100,18 +106,19 @@ void HallwaySubScene::add_lamp(GameObject & obj, vec2 offset, unsigned int fps) void HallwaySubScene::add_sector_number(GameObject & obj, vec2 offset, unsigned int sector_num, Color sector_color) { Asset sector_text_asset{"asset/background/hallway/sectorText_TVOS.png"}; - obj.add_component(sector_text_asset, Sprite::Data{ - .color = sector_color, - .sorting_in_layer = 5, - .order_in_layer = 0, - .size = vec2(0, 100), - .position_offset = offset, - }); + obj.add_component(sector_text_asset, + Sprite::Data{ + .color = sector_color, + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 0, + .size = vec2(0, 100), + .position_offset = offset, + }); Asset sector_num_asset{"asset/background/hallway/sectorNumbers_TVOS.png"}; Sprite & sector_num_sprite = obj.add_component( sector_num_asset, Sprite::Data{ .color = sector_color, - .sorting_in_layer = 5, + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, .order_in_layer = 0, .size = vec2(0, 100), .position_offset = offset + vec2(200, 0), diff --git a/game/background/StartSubScene.cpp b/game/background/StartSubScene.cpp index 5d810c2..547b00d 100644 --- a/game/background/StartSubScene.cpp +++ b/game/background/StartSubScene.cpp @@ -1,5 +1,7 @@ #include "StartSubScene.h" +#include "../Config.h" + #include #include #include @@ -18,17 +20,18 @@ float StartSubScene::create(Scene & scn, float begin_x) { GameObject begin = scn.new_object("start_begin", "background", vec2(begin_x, 0)); Asset begin_asset{"asset/background/start/titleFG_1_TVOS.png"}; begin.add_component(begin_asset, Sprite::Data{ - .sorting_in_layer = 4, + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 0, .size = vec2(0, 800), }); GameObject hole = scn.new_object("start_hole", "background", vec2(begin_x - 250, 140)); Asset hole_asset{"asset/background/start/titleWallHole.png"}; - Sprite & hole_sprite = hole.add_component(hole_asset, Sprite::Data{ - .sorting_in_layer = 4, - .order_in_layer = 1, - .size = vec2(0, 200), - }); + Sprite & hole_sprite = hole.add_component( + hole_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, + .order_in_layer = 1, + .size = vec2(0, 200), + }); hole_sprite.active = false; begin_x += 700; @@ -39,7 +42,7 @@ float StartSubScene::create(Scene & scn, float begin_x) { GameObject end = scn.new_object("start_end", "background", vec2(begin_x, 0)); Asset end_asset{"asset/background/start/titleFG_2_TVOS.png"}; end.add_component(end_asset, Sprite::Data{ - .sorting_in_layer = 4, + .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 1, .size = vec2(0, 800), }); @@ -53,7 +56,7 @@ float StartSubScene::create(Scene & scn, float begin_x) { void StartSubScene::add_lamp(GameObject & obj, vec2 offset, unsigned int fps) { Asset lamp_asset{"asset/background/start/alarmLight_TVOS.png"}; obj.add_component(lamp_asset, Sprite::Data{ - .sorting_in_layer = 5, + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, .order_in_layer = 0, .size = vec2(0, 100), .position_offset = offset, @@ -61,7 +64,7 @@ void StartSubScene::add_lamp(GameObject & obj, vec2 offset, unsigned int fps) { Asset lamp_glow_asset{"asset/background/start/alarmGlow_TVOS.png"}; Sprite & lamp_glow_sprite = obj.add_component( lamp_glow_asset, Sprite::Data{ - .sorting_in_layer = 5, + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, .order_in_layer = 1, .size = vec2(0, 300), .position_offset = offset - vec2(65, -55), @@ -77,7 +80,7 @@ void StartSubScene::add_lamp(GameObject & obj, vec2 offset, unsigned int fps) { void StartSubScene::add_table(GameObject & obj, vec2 offset) { Asset table_asset{"asset/background/start/table.png"}; obj.add_component(table_asset, Sprite::Data{ - .sorting_in_layer = 5, + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, .order_in_layer = 0, .size = vec2(0, 100), .position_offset = offset, @@ -85,7 +88,7 @@ void StartSubScene::add_table(GameObject & obj, vec2 offset) { Asset gramophone_asset{"asset/background/start/gramophone_TVOS.png"}; Sprite & gramophone_sprite = obj.add_component( gramophone_asset, Sprite::Data{ - .sorting_in_layer = 5, + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, .order_in_layer = 1, .size = vec2(0, 100), .position_offset = offset + vec2(0, -50), @@ -100,36 +103,38 @@ void StartSubScene::add_table(GameObject & obj, vec2 offset) { void StartSubScene::add_light(crepe::GameObject & obj, crepe::vec2 offset) { Asset light_asset{"asset/background/start/title_light_TVOS.png"}; obj.add_component(light_asset, Sprite::Data{ - .sorting_in_layer = 5, + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, .order_in_layer = 0, .size = vec2(0, 200), .position_offset = offset, }); Asset light_glow_asset{"asset/background/start/lightEffect2.png"}; - obj.add_component(light_glow_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 1, - .size = vec2(0, 100), - .position_offset = offset + vec2(0, 75), - }); + obj.add_component(light_glow_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 1, + .size = vec2(0, 100), + .position_offset = offset + vec2(0, 75), + }); Asset light_effect_asset{"asset/background/start/lightEffect.png"}; - obj.add_component(light_effect_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 0, - .size = vec2(0, 100), - .position_offset = offset + vec2(0, 350), - }); + obj.add_component(light_effect_asset, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 0, + .size = vec2(0, 100), + .position_offset = offset + vec2(0, 350), + }); } void StartSubScene::add_jetpack_stand(crepe::GameObject & obj, crepe::vec2 offset) { Asset jetpack_stand_asset{"asset/background/start/JetpackStand.png"}; - Sprite & jetpeck_stand_sprite - = obj.add_component(jetpack_stand_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 1, - .size = vec2(0, 70), - .position_offset = offset, - }); + Sprite & jetpeck_stand_sprite = obj.add_component( + jetpack_stand_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 1, + .size = vec2(0, 70), + .position_offset = offset, + }); obj.add_component(jetpeck_stand_sprite, ivec2(34, 46), uvec2(2, 1), Animator::Data{ .fps = 10, @@ -137,23 +142,24 @@ void StartSubScene::add_jetpack_stand(crepe::GameObject & obj, crepe::vec2 offse }) .pause(); Asset do_not_steal = {"asset/background/start/doNotTouchSign_TVOS.png"}; - obj.add_component(do_not_steal, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 1, - .size = vec2(0, 100), - .position_offset = offset + vec2(-75, -25), - }); + obj.add_component(do_not_steal, + Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 1, + .size = vec2(0, 100), + .position_offset = offset + vec2(-75, -25), + }); } void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { GameObject frag_1 = scn.new_object("frag_1", "wall_fragment", vec2(begin_x, 200)); Asset frag_1_asset{"asset/background/start/StartWall_frag1.png"}; - Sprite & frag_1_sprite - = frag_1.add_component(frag_1_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); + Sprite & frag_1_sprite = frag_1.add_component( + frag_1_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 50), + }); frag_1_sprite.active = false; Rigidbody & frag_1_rb = frag_1.add_component(Rigidbody::Data{ .gravity_scale = 10, @@ -169,12 +175,12 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { GameObject frag_2 = scn.new_object("frag_2", "wall_fragment", vec2(begin_x, 180)); Asset frag_2_asset{"asset/background/start/StartWall_frag2.png"}; - Sprite & frag_2_sprite - = frag_2.add_component(frag_2_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); + Sprite & frag_2_sprite = frag_2.add_component( + frag_2_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 50), + }); frag_2_sprite.active = false; Rigidbody & frag_2_rb = frag_2.add_component(Rigidbody::Data{ .gravity_scale = 20, @@ -190,12 +196,12 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { GameObject frag_3 = scn.new_object("frag_3", "wall_fragment", vec2(begin_x, 170)); Asset frag_3_asset{"asset/background/start/StartWall_frag3.png"}; - Sprite & frag_3_sprite - = frag_3.add_component(frag_3_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); + Sprite & frag_3_sprite = frag_3.add_component( + frag_3_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 50), + }); frag_3_sprite.active = false; Rigidbody & frag_3_rb = frag_3.add_component(Rigidbody::Data{ .gravity_scale = 30, @@ -211,12 +217,12 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { GameObject frag_4 = scn.new_object("frag_4", "wall_fragment", vec2(begin_x, 160)); Asset frag_4_asset{"asset/background/start/StartWall_frag4.png"}; - Sprite & frag_4_sprite - = frag_4.add_component(frag_4_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); + Sprite & frag_4_sprite = frag_4.add_component( + frag_4_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 50), + }); frag_4_sprite.active = false; Rigidbody & frag_4_rb = frag_4.add_component(Rigidbody::Data{ .gravity_scale = 40, @@ -232,12 +238,12 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { GameObject frag_5 = scn.new_object("frag_5", "wall_fragment", vec2(begin_x, 150)); Asset frag_5_asset{"asset/background/start/StartWall_frag5.png"}; - Sprite & frag_5_sprite - = frag_5.add_component(frag_5_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); + Sprite & frag_5_sprite = frag_5.add_component( + frag_5_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 50), + }); frag_5_sprite.active = false; Rigidbody & frag_5_rb = frag_5.add_component(Rigidbody::Data{ .gravity_scale = 50, @@ -253,12 +259,12 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { GameObject frag_6 = scn.new_object("frag_6", "wall_fragment", vec2(begin_x, 140)); Asset frag_6_asset{"asset/background/start/StartWall_frag6.png"}; - Sprite & frag_6_sprite - = frag_6.add_component(frag_6_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); + Sprite & frag_6_sprite = frag_6.add_component( + frag_6_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 50), + }); frag_6_sprite.active = false; Rigidbody & frag_6_rb = frag_6.add_component(Rigidbody::Data{ .gravity_scale = 30, @@ -274,12 +280,12 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { GameObject frag_7 = scn.new_object("frag_7", "wall_fragment", vec2(begin_x, 130)); Asset frag_7_asset{"asset/background/start/StartWall_frag7.png"}; - Sprite & frag_7_sprite - = frag_7.add_component(frag_7_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); + Sprite & frag_7_sprite = frag_7.add_component( + frag_7_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 50), + }); frag_7_sprite.active = false; Rigidbody & frag_7_rb = frag_7.add_component(Rigidbody::Data{ .gravity_scale = 20, @@ -295,12 +301,12 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { GameObject frag_8 = scn.new_object("frag_8", "wall_fragment", vec2(begin_x, 120)); Asset frag_8_asset{"asset/background/start/StartWall_frag8.png"}; - Sprite & frag_8_sprite - = frag_8.add_component(frag_8_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); + Sprite & frag_8_sprite = frag_8.add_component( + frag_8_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 50), + }); frag_8_sprite.active = false; Rigidbody & frag_8_rb = frag_8.add_component(Rigidbody::Data{ .gravity_scale = 30, @@ -316,12 +322,12 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { GameObject frag_9 = scn.new_object("frag_9", "wall_fragment", vec2(begin_x, 110)); Asset frag_9_asset{"asset/background/start/StartWall_frag9.png"}; - Sprite & frag_9_sprite - = frag_9.add_component(frag_9_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); + Sprite & frag_9_sprite = frag_9.add_component( + frag_9_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 50), + }); frag_9_sprite.active = false; Rigidbody & frag_9_rb = frag_9.add_component(Rigidbody::Data{ .gravity_scale = 40, @@ -337,12 +343,12 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { GameObject frag_10 = scn.new_object("frag_10", "wall_fragment", vec2(begin_x, 100)); Asset frag_10_asset{"asset/background/start/StartWall_frag10.png"}; - Sprite & frag_10_sprite - = frag_10.add_component(frag_10_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); + Sprite & frag_10_sprite = frag_10.add_component( + frag_10_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 50), + }); frag_10_sprite.active = false; Rigidbody & frag_10_rb = frag_10.add_component(Rigidbody::Data{ .gravity_scale = 50, @@ -358,12 +364,12 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { GameObject frag_11 = scn.new_object("frag_11", "wall_fragment", vec2(begin_x, 90)); Asset frag_11_asset{"asset/background/start/StartWall_frag11.png"}; - Sprite & frag_11_sprite - = frag_11.add_component(frag_11_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); + Sprite & frag_11_sprite = frag_11.add_component( + frag_11_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 50), + }); frag_11_sprite.active = false; Rigidbody & frag_11_rb = frag_11.add_component(Rigidbody::Data{ .gravity_scale = 60, @@ -379,12 +385,12 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { GameObject frag_12 = scn.new_object("frag_12", "wall_fragment", vec2(begin_x, 80)); Asset frag_12_asset{"asset/background/start/StartWall_frag12.png"}; - Sprite & frag_12_sprite - = frag_12.add_component(frag_12_asset, Sprite::Data{ - .sorting_in_layer = 5, - .order_in_layer = 5, - .size = vec2(0, 50), - }); + Sprite & frag_12_sprite = frag_12.add_component( + frag_12_asset, Sprite::Data{ + .sorting_in_layer = SORT_IN_LAY_FORE_BACKGROUND, + .order_in_layer = 5, + .size = vec2(0, 50), + }); frag_12_sprite.active = false; Rigidbody & frag_12_rb = frag_12.add_component(Rigidbody::Data{ .gravity_scale = 70, @@ -404,7 +410,7 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { Sprite & smoke_sprite_1 = smoke_particles_1.add_component( smoke_asset_1, Sprite::Data{ .color = Color(255, 255, 255, 50), - .sorting_in_layer = 15, + .sorting_in_layer = SORT_IN_LAY_PARTICLES_FOREGROUND, .order_in_layer = 0, .size = vec2(0, 100), }); @@ -425,7 +431,7 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { Sprite & smoke_sprite_2 = smoke_particles_2.add_component( smoke_asset_2, Sprite::Data{ .color = Color(255, 255, 255, 50), - .sorting_in_layer = 15, + .sorting_in_layer = SORT_IN_LAY_PARTICLES_FOREGROUND, .order_in_layer = 0, .size = vec2(0, 70), }); diff --git a/mwe/events/include/event.h b/mwe/events/include/event.h index ee1bf52..e1b220b 100644 --- a/mwe/events/include/event.h +++ b/mwe/events/include/event.h @@ -148,7 +148,7 @@ private: }; class ShutDownEvent : public Event { public: - ShutDownEvent() : Event("ShutDownEvent") {}; + ShutDownEvent() : Event("ShutDownEvent"){}; REGISTER_EVENT_TYPE(ShutDownEvent) diff --git a/src/crepe/system/InputSystem.h b/src/crepe/system/InputSystem.h index 45b238b..2cb80e5 100644 --- a/src/crepe/system/InputSystem.h +++ b/src/crepe/system/InputSystem.h @@ -23,7 +23,7 @@ public: /** * \param metadata Metadata of the button pressed */ - ButtonPressEvent(const Metadata & metadata) : metadata(metadata) {}; + ButtonPressEvent(const Metadata & metadata) : metadata(metadata){}; }; //! Event triggered when the mouse enters a button class ButtonEnterEvent : public Event { @@ -33,7 +33,7 @@ public: /** * \param metadata Metadata of the button pressed */ - ButtonEnterEvent(const Metadata & metadata) : metadata(metadata) {}; + ButtonEnterEvent(const Metadata & metadata) : metadata(metadata){}; }; //! Event triggered when the mouse leaves a button class ButtonExitEvent : public Event { @@ -43,7 +43,7 @@ public: /** * \param metadata Metadata of the button pressed */ - ButtonExitEvent(const Metadata & metadata) : metadata(metadata) {}; + ButtonExitEvent(const Metadata & metadata) : metadata(metadata){}; }; /** -- cgit v1.2.3 From 799a376aeecd9bdc712e89324cbe9153206839c9 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Sat, 21 Dec 2024 11:38:19 +0100 Subject: Added comments --- game/Config.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'game') diff --git a/game/Config.h b/game/Config.h index 7a83ee6..0d6f880 100644 --- a/game/Config.h +++ b/game/Config.h @@ -1,11 +1,9 @@ #pragma once -static constexpr int SORT_IN_LAY_BACK_BACKGROUND = 3; -static constexpr int SORT_IN_LAY_BACKGROUND = 4; -static constexpr int SORT_IN_LAY_FORE_BACKGROUND = 5; -static constexpr int SORT_IN_LAY_PARTICLES_BACKGROUND = 6; -static constexpr int SORT_IN_LAY_OBSTACLES = 8; -static constexpr int SORT_IN_LAY_PLAYER = 10; -static constexpr int SORT_IN_LAY_PARTICLES_FOREGROUND = 15; - - +static constexpr int SORT_IN_LAY_BACK_BACKGROUND = 3; // For all scenes +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_PLAYER = 10; // Only for GameScene +static constexpr int SORT_IN_LAY_PARTICLES_FOREGROUND = 15; // Only for GameScene -- cgit v1.2.3 From e72dc913e7b35bcd2f6ba8107ea46e383afd25e1 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Sat, 21 Dec 2024 11:52:48 +0100 Subject: Added more to Config.h --- game/Config.h | 6 ++++++ game/GameScene.cpp | 3 ++- game/background/AquariumSubScene.cpp | 12 ++++++------ game/background/ForestSubScene.cpp | 8 ++++---- game/background/HallwaySubScene.cpp | 12 ++++++------ game/background/StartSubScene.cpp | 4 ++-- 6 files changed, 26 insertions(+), 19 deletions(-) (limited to 'game') diff --git a/game/Config.h b/game/Config.h index 0d6f880..7c16b47 100644 --- a/game/Config.h +++ b/game/Config.h @@ -7,3 +7,9 @@ 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_PLAYER = 10; // Only for GameScene static constexpr int SORT_IN_LAY_PARTICLES_FOREGROUND = 15; // Only for GameScene + +static constexpr int GAME_HEIGHT = 800; // In game units + +static constexpr int VIEWPORT_X = 1100; // In game units +// 'GAME_HEIGHT' (below) should be replaced by '500' when game development is finished +static constexpr int VIEWPORT_Y = GAME_HEIGHT; // In game units diff --git a/game/GameScene.cpp b/game/GameScene.cpp index 9606244..db1a753 100644 --- a/game/GameScene.cpp +++ b/game/GameScene.cpp @@ -1,4 +1,5 @@ #include "GameScene.h" +#include "Config.h" #include "MoveCameraManualyScript.h" #include "PlayerSubScene.h" #include "StartGameScript.h" @@ -29,7 +30,7 @@ void GameScene::load_scene() { BackgroundSubScene background(*this); GameObject camera = new_object("camera", "camera", vec2(650, 0)); - camera.add_component(ivec2(990, 720), vec2(1100, 800), + camera.add_component(ivec2(990, 720), vec2(VIEWPORT_X, VIEWPORT_Y), Camera::Data{ .bg_color = Color::RED, }); diff --git a/game/background/AquariumSubScene.cpp b/game/background/AquariumSubScene.cpp index 9994a9e..579e633 100644 --- a/game/background/AquariumSubScene.cpp +++ b/game/background/AquariumSubScene.cpp @@ -21,7 +21,7 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 0, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 600; @@ -32,7 +32,7 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 2, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 400; @@ -45,7 +45,7 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 3, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 400; @@ -56,7 +56,7 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 4, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 400; @@ -69,7 +69,7 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 5, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 600; @@ -81,7 +81,7 @@ float AquariumSubScene::create(Scene & scn, float begin_x) { Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 1, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 600; diff --git a/game/background/ForestSubScene.cpp b/game/background/ForestSubScene.cpp index f0848f2..7eac53a 100644 --- a/game/background/ForestSubScene.cpp +++ b/game/background/ForestSubScene.cpp @@ -26,7 +26,7 @@ float ForestSubScene::create(Scene & scn, float begin_x, std::string unique_bg_n begin.add_component(begin_asset, Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 0, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 800; @@ -38,7 +38,7 @@ float ForestSubScene::create(Scene & scn, float begin_x, std::string unique_bg_n Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 2, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 800; @@ -50,7 +50,7 @@ float ForestSubScene::create(Scene & scn, float begin_x, std::string unique_bg_n Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 3, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 800; @@ -61,7 +61,7 @@ float ForestSubScene::create(Scene & scn, float begin_x, std::string unique_bg_n end.add_component(end_asset, Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 1, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 600; diff --git a/game/background/HallwaySubScene.cpp b/game/background/HallwaySubScene.cpp index b5e3635..2aa9bab 100644 --- a/game/background/HallwaySubScene.cpp +++ b/game/background/HallwaySubScene.cpp @@ -18,7 +18,7 @@ float HallwaySubScene::create(Scene & scn, float begin_x, unsigned int sector_nu begin.add_component(begin_asset, Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 0, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 600; @@ -32,7 +32,7 @@ float HallwaySubScene::create(Scene & scn, float begin_x, unsigned int sector_nu Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 2, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 600; @@ -42,7 +42,7 @@ float HallwaySubScene::create(Scene & scn, float begin_x, unsigned int sector_nu Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 3, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 200; @@ -52,7 +52,7 @@ float HallwaySubScene::create(Scene & scn, float begin_x, unsigned int sector_nu Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 4, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 400; @@ -64,7 +64,7 @@ float HallwaySubScene::create(Scene & scn, float begin_x, unsigned int sector_nu Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 5, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 600; @@ -73,7 +73,7 @@ float HallwaySubScene::create(Scene & scn, float begin_x, unsigned int sector_nu end.add_component(end_asset, Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 1, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 600; diff --git a/game/background/StartSubScene.cpp b/game/background/StartSubScene.cpp index 547b00d..c769a5f 100644 --- a/game/background/StartSubScene.cpp +++ b/game/background/StartSubScene.cpp @@ -22,7 +22,7 @@ float StartSubScene::create(Scene & scn, float begin_x) { begin.add_component(begin_asset, Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 0, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); GameObject hole = scn.new_object("start_hole", "background", vec2(begin_x - 250, 140)); Asset hole_asset{"asset/background/start/titleWallHole.png"}; @@ -44,7 +44,7 @@ float StartSubScene::create(Scene & scn, float begin_x) { end.add_component(end_asset, Sprite::Data{ .sorting_in_layer = SORT_IN_LAY_BACKGROUND, .order_in_layer = 1, - .size = vec2(0, 800), + .size = vec2(0, GAME_HEIGHT), }); begin_x += 100; -- cgit v1.2.3 From 94f99f931e22b5eecbc26b19038788e620ff27ee Mon Sep 17 00:00:00 2001 From: Max-001 Date: Sat, 21 Dec 2024 11:53:29 +0100 Subject: Deleted iostream include --- game/GameScene.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'game') diff --git a/game/GameScene.cpp b/game/GameScene.cpp index db1a753..a224cfd 100644 --- a/game/GameScene.cpp +++ b/game/GameScene.cpp @@ -21,7 +21,6 @@ #include #include #include -#include using namespace crepe; using namespace std; -- cgit v1.2.3 From e7599e648ea24d5e8a27bd9f4f162ef1a7c53d21 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Sat, 21 Dec 2024 12:25:27 +0100 Subject: Added collision layers to Config.h --- game/Config.h | 6 ++++++ game/GameScene.cpp | 13 +++++++++++++ game/PlayerSubScene.cpp | 3 ++- game/background/StartSubScene.cpp | 38 +++++++++++++++++++++++++------------- 4 files changed, 46 insertions(+), 14 deletions(-) (limited to 'game') diff --git a/game/Config.h b/game/Config.h index 7c16b47..ec753df 100644 --- a/game/Config.h +++ b/game/Config.h @@ -8,6 +8,12 @@ static constexpr int SORT_IN_LAY_OBSTACLES = 8; // Only for GameScene static constexpr int SORT_IN_LAY_PLAYER = 10; // 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 +static constexpr int COLL_LAY_BOT_LOW = 2; // Only for GameScene +static constexpr int COLL_LAY_BOT_HIGH = 3; // Only for GameScene +static constexpr int COLL_LAY_PLAYER = 4; // Only for GameScene +static constexpr int COLL_LAY_WALL_FRAGS = 5; // Only for GameScene + static constexpr int GAME_HEIGHT = 800; // In game units static constexpr int VIEWPORT_X = 1100; // In game units diff --git a/game/GameScene.cpp b/game/GameScene.cpp index a224cfd..91da092 100644 --- a/game/GameScene.cpp +++ b/game/GameScene.cpp @@ -41,11 +41,24 @@ void GameScene::load_scene() { GameObject floor = new_object("floor", "game_world", vec2(0, 325)); floor.add_component(Rigidbody::Data{ .body_type = Rigidbody::BodyType::STATIC, + .collision_layer = COLL_LAY_BOT_TOP, }); floor.add_component(vec2(INFINITY, 200)); + GameObject floor_low = new_object("floor_low", "game_world", vec2(0, 350)); + floor_low.add_component(Rigidbody::Data{ + .body_type = Rigidbody::BodyType::STATIC, + .collision_layer = COLL_LAY_BOT_LOW, + }); + floor_low.add_component(vec2(INFINITY, 200)); + GameObject floor_high = new_object("floor_high", "game_world", vec2(0, 300)); + floor_high.add_component(Rigidbody::Data{ + .body_type = Rigidbody::BodyType::STATIC, + .collision_layer = COLL_LAY_BOT_HIGH, + }); GameObject ceiling = new_object("ceiling", "game_world", vec2(0, -325)); ceiling.add_component(Rigidbody::Data{ .body_type = Rigidbody::BodyType::STATIC, + .collision_layer = COLL_LAY_BOT_TOP, }); ceiling.add_component(vec2(INFINITY, 200)); diff --git a/game/PlayerSubScene.cpp b/game/PlayerSubScene.cpp index d81dd34..b361a82 100644 --- a/game/PlayerSubScene.cpp +++ b/game/PlayerSubScene.cpp @@ -56,7 +56,8 @@ PlayerSubScene::PlayerSubScene(Scene & scn) { .gravity_scale = 20, .body_type = Rigidbody::BodyType::DYNAMIC, .linear_velocity = vec2(100, 0), - .collision_layer = 10, + .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_PLAYER, }); player.add_component(vec2(50, 50)); player.add_component().set_script().active = false; diff --git a/game/background/StartSubScene.cpp b/game/background/StartSubScene.cpp index c769a5f..a918c05 100644 --- a/game/background/StartSubScene.cpp +++ b/game/background/StartSubScene.cpp @@ -168,7 +168,8 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { .angular_velocity = 500, .angular_velocity_coefficient = 0.55, .elasticity_coefficient = 0.5, - .collision_layer = 5, + .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_WALL_FRAGS, }); frag_1_rb.active = false; frag_1.add_component(25); @@ -189,7 +190,8 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { .angular_velocity = 400, .angular_velocity_coefficient = 0.55, .elasticity_coefficient = 0.5, - .collision_layer = 5, + .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_WALL_FRAGS, }); frag_2_rb.active = false; frag_2.add_component(55); @@ -210,7 +212,8 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { .angular_velocity = 300, .angular_velocity_coefficient = 0.55, .elasticity_coefficient = 0.5, - .collision_layer = 5, + .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_WALL_FRAGS, }); frag_3_rb.active = false; frag_3.add_component(35); @@ -231,7 +234,8 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { .angular_velocity = 200, .angular_velocity_coefficient = 0.55, .elasticity_coefficient = 0.5, - .collision_layer = 5, + .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_WALL_FRAGS, }); frag_4_rb.active = false; frag_4.add_component(60); @@ -252,7 +256,8 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { .angular_velocity = 100, .angular_velocity_coefficient = 0.55, .elasticity_coefficient = 0.5, - .collision_layer = 5, + .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_WALL_FRAGS, }); frag_5_rb.active = false; frag_5.add_component(5); @@ -273,7 +278,8 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { .angular_velocity = 100, .angular_velocity_coefficient = 0.55, .elasticity_coefficient = 0.5, - .collision_layer = 5, + .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_WALL_FRAGS, }); frag_6_rb.active = false; frag_6.add_component(30); @@ -294,7 +300,8 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { .angular_velocity = 800, .angular_velocity_coefficient = 0.55, .elasticity_coefficient = 0.5, - .collision_layer = 5, + .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_WALL_FRAGS, }); frag_7_rb.active = false; frag_7.add_component(45); @@ -315,7 +322,8 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { .angular_velocity = 500, .angular_velocity_coefficient = 0.55, .elasticity_coefficient = 0.5, - .collision_layer = 5, + .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_WALL_FRAGS, }); frag_8_rb.active = false; frag_8.add_component(25); @@ -336,7 +344,8 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { .angular_velocity = 500, .angular_velocity_coefficient = 0.55, .elasticity_coefficient = 0.5, - .collision_layer = 5, + .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_WALL_FRAGS, }); frag_9_rb.active = false; frag_9.add_component(15); @@ -357,12 +366,13 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { .angular_velocity = 300, .angular_velocity_coefficient = 0.55, .elasticity_coefficient = 0.5, - .collision_layer = 5, + .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_WALL_FRAGS, }); frag_10_rb.active = false; frag_10.add_component(60); - GameObject frag_11 = scn.new_object("frag_11", "wall_fragment", vec2(begin_x, 90)); + GameObject frag_11 = scn.new_object("frag_11", "wall_fragment", vec2(begin_x, 70)); Asset frag_11_asset{"asset/background/start/StartWall_frag11.png"}; Sprite & frag_11_sprite = frag_11.add_component( frag_11_asset, Sprite::Data{ @@ -378,7 +388,8 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { .angular_velocity = 200, .angular_velocity_coefficient = 0.55, .elasticity_coefficient = 0.5, - .collision_layer = 5, + .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_WALL_FRAGS, }); frag_11_rb.active = false; frag_11.add_component(5); @@ -399,7 +410,8 @@ void StartSubScene::create_wall_fragments(crepe::Scene & scn, float begin_x) { .angular_velocity = 100, .angular_velocity_coefficient = 0.55, .elasticity_coefficient = 0.5, - .collision_layer = 5, + .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_WALL_FRAGS, }); frag_12_rb.active = false; frag_12.add_component(50); -- cgit v1.2.3