From 07615060da6c211e08a3d7f2e1bb9e99ffc05364 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Mon, 6 Jan 2025 17:49:39 +0100 Subject: moved and updated files --- game/CMakeLists.txt | 20 ++-- game/coins/CoinData.h | 11 -- game/coins/CoinScript.cpp | 1 - game/coins/CoinSystemScript.cpp | 2 +- game/coins/CoinSystemScript.h | 10 +- game/main.cpp | 5 +- game/mainmenu/BannerSubScene.cpp | 42 ------- game/mainmenu/BannerSubScene.h | 19 --- game/mainmenu/ButtonSetMainMenuScript.cpp | 19 --- game/mainmenu/ButtonSetMainMenuScript.h | 14 --- game/mainmenu/ButtonSetShopScript.cpp | 19 --- game/mainmenu/ButtonSetShopScript.h | 14 --- game/mainmenu/ButtonSubScene.cpp | 128 --------------------- game/mainmenu/ButtonSubScene.h | 58 ---------- game/mainmenu/ButtonTransitionPreviewScript.cpp | 24 ---- game/mainmenu/ButtonTransitionPreviewScript.h | 11 -- game/mainmenu/IButtonScript.cpp | 33 ------ game/mainmenu/IButtonScript.h | 12 -- game/mainmenu/ITransitionScript.cpp | 31 ----- game/mainmenu/ITransitionScript.h | 13 --- game/mainmenu/MainMenuConfig.h | 39 ------- game/mainmenu/MainMenuScene.cpp | 98 ---------------- game/mainmenu/MainMenuScene.h | 11 -- game/mainmenu/ShopMenuScene.cpp | 44 ------- game/mainmenu/ShopMenuScene.h | 11 -- game/mainmenu/TransitionStartScript.cpp | 21 ---- game/mainmenu/TransitionStartScript.h | 10 -- game/menus/BannerSubScene.cpp | 42 +++++++ game/menus/BannerSubScene.h | 19 +++ game/menus/ButtonSetMainMenuScript.cpp | 19 +++ game/menus/ButtonSetMainMenuScript.h | 14 +++ game/menus/ButtonSetShopScript.cpp | 19 +++ game/menus/ButtonSetShopScript.h | 14 +++ game/menus/ButtonSubScene.cpp | 128 +++++++++++++++++++++ game/menus/ButtonSubScene.h | 57 +++++++++ game/menus/IButtonScript.cpp | 33 ++++++ game/menus/IButtonScript.h | 12 ++ game/menus/MenusConfig.h | 18 +++ .../mainmenu/ButtonTransitionPreviewScript.cpp | 24 ++++ .../menus/mainmenu/ButtonTransitionPreviewScript.h | 11 ++ game/menus/mainmenu/ITransitionScript.cpp | 30 +++++ game/menus/mainmenu/ITransitionScript.h | 13 +++ game/menus/mainmenu/MainMenuConfig.h | 22 ++++ game/menus/mainmenu/MainMenuScene.cpp | 99 ++++++++++++++++ game/menus/mainmenu/MainMenuScene.h | 11 ++ game/menus/mainmenu/TransitionStartScript.cpp | 20 ++++ game/menus/mainmenu/TransitionStartScript.h | 10 ++ game/menus/shop/ShopMenuScene.cpp | 44 +++++++ game/menus/shop/ShopMenuScene.h | 11 ++ 49 files changed, 693 insertions(+), 697 deletions(-) delete mode 100644 game/coins/CoinData.h delete mode 100644 game/mainmenu/BannerSubScene.cpp delete mode 100644 game/mainmenu/BannerSubScene.h delete mode 100644 game/mainmenu/ButtonSetMainMenuScript.cpp delete mode 100644 game/mainmenu/ButtonSetMainMenuScript.h delete mode 100644 game/mainmenu/ButtonSetShopScript.cpp delete mode 100644 game/mainmenu/ButtonSetShopScript.h delete mode 100644 game/mainmenu/ButtonSubScene.cpp delete mode 100644 game/mainmenu/ButtonSubScene.h delete mode 100644 game/mainmenu/ButtonTransitionPreviewScript.cpp delete mode 100644 game/mainmenu/ButtonTransitionPreviewScript.h delete mode 100644 game/mainmenu/IButtonScript.cpp delete mode 100644 game/mainmenu/IButtonScript.h delete mode 100644 game/mainmenu/ITransitionScript.cpp delete mode 100644 game/mainmenu/ITransitionScript.h delete mode 100644 game/mainmenu/MainMenuConfig.h delete mode 100644 game/mainmenu/MainMenuScene.cpp delete mode 100644 game/mainmenu/MainMenuScene.h delete mode 100644 game/mainmenu/ShopMenuScene.cpp delete mode 100644 game/mainmenu/ShopMenuScene.h delete mode 100644 game/mainmenu/TransitionStartScript.cpp delete mode 100644 game/mainmenu/TransitionStartScript.h create mode 100644 game/menus/BannerSubScene.cpp create mode 100644 game/menus/BannerSubScene.h create mode 100644 game/menus/ButtonSetMainMenuScript.cpp create mode 100644 game/menus/ButtonSetMainMenuScript.h create mode 100644 game/menus/ButtonSetShopScript.cpp create mode 100644 game/menus/ButtonSetShopScript.h create mode 100644 game/menus/ButtonSubScene.cpp create mode 100644 game/menus/ButtonSubScene.h create mode 100644 game/menus/IButtonScript.cpp create mode 100644 game/menus/IButtonScript.h create mode 100644 game/menus/MenusConfig.h create mode 100644 game/menus/mainmenu/ButtonTransitionPreviewScript.cpp create mode 100644 game/menus/mainmenu/ButtonTransitionPreviewScript.h create mode 100644 game/menus/mainmenu/ITransitionScript.cpp create mode 100644 game/menus/mainmenu/ITransitionScript.h create mode 100644 game/menus/mainmenu/MainMenuConfig.h create mode 100644 game/menus/mainmenu/MainMenuScene.cpp create mode 100644 game/menus/mainmenu/MainMenuScene.h create mode 100644 game/menus/mainmenu/TransitionStartScript.cpp create mode 100644 game/menus/mainmenu/TransitionStartScript.h create mode 100644 game/menus/shop/ShopMenuScene.cpp create mode 100644 game/menus/shop/ShopMenuScene.h diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index edc8a93..949312f 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -22,16 +22,16 @@ add_executable(main player/PlayerEndScript.cpp background/StartSubScene.cpp main.cpp - mainmenu/IButtonScript.cpp - mainmenu/ButtonSubScene.cpp - mainmenu/MainMenuScene.cpp - mainmenu/ITransitionScript.cpp - mainmenu/TransitionStartScript.cpp - mainmenu/ButtonTransitionPreviewScript.cpp - mainmenu/ShopMenuScene.cpp - mainmenu/BannerSubScene.cpp - mainmenu/ButtonSetShopScript.cpp - mainmenu/ButtonSetMainMenuScript.cpp + menus/BannerSubScene.cpp + menus/ButtonSubScene.cpp + menus/IButtonScript.cpp + menus/ButtonSetShopScript.cpp + menus/ButtonSetMainMenuScript.cpp + menus/shop/ShopMenuScene.cpp + menus/mainmenu/ButtonTransitionPreviewScript.cpp + menus/mainmenu/ITransitionScript.cpp + menus/mainmenu/MainMenuScene.cpp + menus/mainmenu/TransitionStartScript.cpp coins/CoinSubScene.cpp coins/CoinPool.cpp coins/CoinSystemScript.cpp diff --git a/game/coins/CoinData.h b/game/coins/CoinData.h deleted file mode 100644 index 09b3448..0000000 --- a/game/coins/CoinData.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "types.h" -#include - -struct CoinData{ - crepe::vec2 start_location = {0,0}; - std::string name = ""; - bool active = false; - CoinData(crepe::vec2 start_location) : start_location(start_location),name(""), active(false) {} -}; diff --git a/game/coins/CoinScript.cpp b/game/coins/CoinScript.cpp index 5a1e922..e40f658 100644 --- a/game/coins/CoinScript.cpp +++ b/game/coins/CoinScript.cpp @@ -9,7 +9,6 @@ using namespace std; bool CoinScript::on_collision(const CollisionEvent & collisionData){ if(collisionData.info.other.metadata.name != PLAYER_NAME) return true; - //collide with player this->get_component().active = false; this->get_component().active = false; SaveManager & savemgr = this->get_save_manager(); diff --git a/game/coins/CoinSystemScript.cpp b/game/coins/CoinSystemScript.cpp index 41b1d3d..b77c597 100644 --- a/game/coins/CoinSystemScript.cpp +++ b/game/coins/CoinSystemScript.cpp @@ -10,7 +10,7 @@ using namespace crepe; using namespace std; -std::vector CoinSystemScript::coin_locations; +std::vector CoinSystemScript::coin_locations; void CoinSystemScript::init() { engine.seed(rd()); diff --git a/game/coins/CoinSystemScript.h b/game/coins/CoinSystemScript.h index 4bafa01..f558f08 100644 --- a/game/coins/CoinSystemScript.h +++ b/game/coins/CoinSystemScript.h @@ -1,6 +1,7 @@ #pragma once -#include "CoinData.h" +#include "types.h" +#include #include "api/CircleCollider.h" #include "api/Script.h" #include "api/Sprite.h" @@ -8,6 +9,13 @@ #include class CoinSystemScript : public crepe::Script { +private: + struct CoinData{ + crepe::vec2 start_location = {0,0}; + std::string name = ""; + bool active = false; + CoinData(crepe::vec2 start_location) : start_location(start_location),name(""), active(false) {} + }; public: CoinSystemScript() {}; void init() override; diff --git a/game/main.cpp b/game/main.cpp index ddc596d..b9bebfb 100644 --- a/game/main.cpp +++ b/game/main.cpp @@ -2,8 +2,9 @@ #include #include "GameScene.h" -#include "mainmenu/MainMenuScene.h" -#include "mainmenu/ShopMenuScene.h" +#include "menus/mainmenu/MainMenuScene.h" +#include "menus/shop/ShopMenuScene.h" + using namespace crepe; diff --git a/game/mainmenu/BannerSubScene.cpp b/game/mainmenu/BannerSubScene.cpp deleted file mode 100644 index 0659d96..0000000 --- a/game/mainmenu/BannerSubScene.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "BannerSubScene.h" -#include "MainMenuConfig.h" -#include "../Config.h" - - -#include -#include -#include - -using namespace crepe; -using namespace std; - -void BannerSubScene::create(Scene & scn,const Data & data){ - GameObject menu_banner = scn.new_object("menu_banner","", {0,-414}); - menu_banner.add_component( - Asset("asset/ui/settings_container/top_middle_setting.png"), - Sprite::Data{ - .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1, - .size = {1100,88}, - }); - menu_banner.add_component( - Asset("asset/ui/settings_container/top_2_middle_setting.png"), - Sprite::Data{ - .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1, - .size = {1100,66}, - .position_offset {0,77}, - }); - menu_banner.add_component( - Asset("asset/ui/settings_container/banner_bottom.png"), - Sprite::Data{ - .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1, - .size = {1100,7}, - .position_offset {0,113}, - }); - crepe::vec2 size = {data.banner_title_width,(data.banner_title_width/data.banner_title.size())*2}; - - menu_banner.add_component( size, FONT, Text::Data{ - .world_space = true, - .text_color = Color::WHITE, - }, data.banner_title_offset + FONTOFFSET, data.banner_title); - -} diff --git a/game/mainmenu/BannerSubScene.h b/game/mainmenu/BannerSubScene.h deleted file mode 100644 index 341943d..0000000 --- a/game/mainmenu/BannerSubScene.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "types.h" -#include - -namespace crepe { -class Scene; -} - -class BannerSubScene { -public: -struct Data{ - const std::string & banner_title = "NODATA"; - const float banner_title_width = 100; - const crepe::vec2 & banner_title_offset = {0,0}; - }; -public: - void create(crepe::Scene & scn,const Data & data); -}; diff --git a/game/mainmenu/ButtonSetMainMenuScript.cpp b/game/mainmenu/ButtonSetMainMenuScript.cpp deleted file mode 100644 index 808d8a2..0000000 --- a/game/mainmenu/ButtonSetMainMenuScript.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "ButtonSetMainMenuScript.h" -#include "MainMenuConfig.h" -#include "iostream" - -using namespace crepe; -using namespace std; - -void ButtonSetMainMenuScript::init(){ - cout << "script init" << endl; - IButtonScript::init(); - this->subscribe([this](const ButtonPressEvent& e) { return this->on_button_press(e); }); -} - -bool ButtonSetMainMenuScript::on_button_press(const ButtonPressEvent& e){ - this->set_next_scene(MainMenuConfig::MAINMENU_SCENE); - cout << "Start triggered:" << e.metadata.game_object_id << std::endl; - return false; -} - diff --git a/game/mainmenu/ButtonSetMainMenuScript.h b/game/mainmenu/ButtonSetMainMenuScript.h deleted file mode 100644 index 44c21aa..0000000 --- a/game/mainmenu/ButtonSetMainMenuScript.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "IButtonScript.h" -#include - -class ButtonSetMainMenuScript : public IButtonScript { -public: - void init() override; - bool on_button_press(const crepe::ButtonPressEvent& e); -private: - float velocity = 20; -protected: - bool transition = false; -}; diff --git a/game/mainmenu/ButtonSetShopScript.cpp b/game/mainmenu/ButtonSetShopScript.cpp deleted file mode 100644 index 0c855ec..0000000 --- a/game/mainmenu/ButtonSetShopScript.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "ButtonSetShopScript.h" -#include "MainMenuConfig.h" -#include "iostream" - -using namespace crepe; -using namespace std; - -void ButtonSetShopScript::init(){ - cout << "script init" << endl; - IButtonScript::init(); - this->subscribe([this](const ButtonPressEvent& e) { return this->on_button_press(e); }); -} - -bool ButtonSetShopScript::on_button_press(const ButtonPressEvent& e){ - this->set_next_scene(MainMenuConfig::SHOP_SCENE); - cout << "Start triggered:" << e.metadata.game_object_id << std::endl; - return false; -} - diff --git a/game/mainmenu/ButtonSetShopScript.h b/game/mainmenu/ButtonSetShopScript.h deleted file mode 100644 index 51db928..0000000 --- a/game/mainmenu/ButtonSetShopScript.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "IButtonScript.h" -#include - -class ButtonSetShopScript : public IButtonScript { -public: - void init() override; - bool on_button_press(const crepe::ButtonPressEvent& e); -private: - float velocity = 20; -protected: - bool transition = false; -}; diff --git a/game/mainmenu/ButtonSubScene.cpp b/game/mainmenu/ButtonSubScene.cpp deleted file mode 100644 index 760fc0d..0000000 --- a/game/mainmenu/ButtonSubScene.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "ButtonSubScene.h" -#include "ButtonSetMainMenuScript.h" -#include "ButtonSetShopScript.h" -#include "ButtonTransitionPreviewScript.h" -#include "IButtonScript.h" -#include "MainMenuConfig.h" -#include "../Config.h" -#include "api/Color.h" - -#include -#include -#include -#include -#include - -using namespace crepe; -using namespace std; - -void ButtonSubScene::create(Scene & scn,const Data & data){ - GameObject button_object = scn.new_object("button",data.tag,data.position,0,data.scale); - this->set_button_overlay(button_object,data); - this->btn_text(button_object,data); - this->set_script(button_object,data); - this->set_icon(button_object,data); -} - -void ButtonSubScene::btn_text(crepe::GameObject & button_object,const Data & data){ - - crepe::vec2 size = {data.text_width,(data.text_width/data.text.size())*2}; - button_object.add_component(size, FONT,Text::Data{ - .world_space = data.worldspace, - .text_color = Color::WHITE, - }, data.text_offset+FONTOFFSET, data.text); -} - -void ButtonSubScene::set_script(crepe::GameObject & button_object,const Data & data){ - switch (data.script_type) { - case ScriptSelect::PREVIEW: - button_object.add_component().set_script(); - break; - case ScriptSelect::SHOP: - button_object.add_component().set_script(); - break; - case ScriptSelect::MAINMENU: - button_object.add_component().set_script(); - break; - case ScriptSelect::NONE: - button_object.add_component().set_script(); - break; - } -} - -void ButtonSubScene::set_icon(crepe::GameObject & button_object,const Data & data){ - switch (data.icon_type) { - case IconSelect::SHOP: - button_object.add_component(Asset("asset/ui/buttonCoinsSmall.png"),Sprite::Data{ - .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+3, - .size = MainMenuConfig::ICON_SIZE, - .position_offset = data.icon_offset, - .world_space = data.worldspace, - }); - break; - case IconSelect::COINS: - button_object.add_component(Asset("asset/ui/buttonCoinsSmall.png"),Sprite::Data{ - .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+3, - .size = MainMenuConfig::ICON_SIZE, - .position_offset = data.icon_offset, - .world_space = data.worldspace, - }); - break; - case IconSelect::NONE: - break; - } -} - -void ButtonSubScene::set_button_overlay(crepe::GameObject & button_object,const Data & data){ - switch (data.button_type) { - case ButtonSelect::LARGE: - this->large_btn_overlay(button_object,data); - break; - case ButtonSelect::SMALL: - this->small_btn_overlay(button_object,data); - break; - } -} - -void ButtonSubScene::large_btn_overlay(crepe::GameObject & button_object,const Data & data){ - button_object.add_component(Asset("asset/ui/buttonBacking.png"),Sprite::Data{ - .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1, - .size = MainMenuConfig::LARGE_OVERLAY_SIZE, - .world_space = data.worldspace, - }); - button_object.add_component