aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2025-01-06 17:49:39 +0100
committerJAROWMR <jarorutjes07@gmail.com>2025-01-06 17:49:39 +0100
commit07615060da6c211e08a3d7f2e1bb9e99ffc05364 (patch)
treee272fd896ac25aa7ac6d7b4c20dbe5c49a042dce /game
parentce655acf72c5d5be62497dbaac41af7ef49be411 (diff)
moved and updated files
Diffstat (limited to 'game')
-rw-r--r--game/CMakeLists.txt20
-rw-r--r--game/coins/CoinData.h11
-rw-r--r--game/coins/CoinScript.cpp1
-rw-r--r--game/coins/CoinSystemScript.cpp2
-rw-r--r--game/coins/CoinSystemScript.h10
-rw-r--r--game/main.cpp5
-rw-r--r--game/mainmenu/ITransitionScript.cpp31
-rw-r--r--game/mainmenu/MainMenuConfig.h39
-rw-r--r--game/menus/BannerSubScene.cpp (renamed from game/mainmenu/BannerSubScene.cpp)8
-rw-r--r--game/menus/BannerSubScene.h (renamed from game/mainmenu/BannerSubScene.h)0
-rw-r--r--game/menus/ButtonSetMainMenuScript.cpp (renamed from game/mainmenu/ButtonSetMainMenuScript.cpp)4
-rw-r--r--game/menus/ButtonSetMainMenuScript.h (renamed from game/mainmenu/ButtonSetMainMenuScript.h)0
-rw-r--r--game/menus/ButtonSetShopScript.cpp (renamed from game/mainmenu/ButtonSetShopScript.cpp)4
-rw-r--r--game/menus/ButtonSetShopScript.h (renamed from game/mainmenu/ButtonSetShopScript.h)0
-rw-r--r--game/menus/ButtonSubScene.cpp (renamed from game/mainmenu/ButtonSubScene.cpp)36
-rw-r--r--game/menus/ButtonSubScene.h (renamed from game/mainmenu/ButtonSubScene.h)1
-rw-r--r--game/menus/IButtonScript.cpp (renamed from game/mainmenu/IButtonScript.cpp)0
-rw-r--r--game/menus/IButtonScript.h (renamed from game/mainmenu/IButtonScript.h)0
-rw-r--r--game/menus/MenusConfig.h18
-rw-r--r--game/menus/mainmenu/ButtonTransitionPreviewScript.cpp (renamed from game/mainmenu/ButtonTransitionPreviewScript.cpp)4
-rw-r--r--game/menus/mainmenu/ButtonTransitionPreviewScript.h (renamed from game/mainmenu/ButtonTransitionPreviewScript.h)2
-rw-r--r--game/menus/mainmenu/ITransitionScript.cpp30
-rw-r--r--game/menus/mainmenu/ITransitionScript.h (renamed from game/mainmenu/ITransitionScript.h)0
-rw-r--r--game/menus/mainmenu/MainMenuConfig.h22
-rw-r--r--game/menus/mainmenu/MainMenuScene.cpp (renamed from game/mainmenu/MainMenuScene.cpp)33
-rw-r--r--game/menus/mainmenu/MainMenuScene.h (renamed from game/mainmenu/MainMenuScene.h)0
-rw-r--r--game/menus/mainmenu/TransitionStartScript.cpp (renamed from game/mainmenu/TransitionStartScript.cpp)5
-rw-r--r--game/menus/mainmenu/TransitionStartScript.h (renamed from game/mainmenu/TransitionStartScript.h)0
-rw-r--r--game/menus/shop/ShopMenuScene.cpp (renamed from game/mainmenu/ShopMenuScene.cpp)10
-rw-r--r--game/menus/shop/ShopMenuScene.h (renamed from game/mainmenu/ShopMenuScene.h)0
30 files changed, 146 insertions, 150 deletions
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 <string>
-
-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<Sprite>().active = false;
this->get_component<CircleCollider>().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<CoinData> CoinSystemScript::coin_locations;
+std::vector<CoinSystemScript::CoinData> 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 <string>
#include "api/CircleCollider.h"
#include "api/Script.h"
#include "api/Sprite.h"
@@ -8,6 +9,13 @@
#include <random>
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 <crepe/api/Script.h>
#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/ITransitionScript.cpp b/game/mainmenu/ITransitionScript.cpp
deleted file mode 100644
index e923073..0000000
--- a/game/mainmenu/ITransitionScript.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "ITransitionScript.h"
-#include "api/Rigidbody.h"
-#include "api/Transform.h"
-#include "iostream"
-#include <crepe/api/Camera.h>
-#include "MainMenuConfig.h"
-#include "types.h"
-
-using namespace crepe;
-using namespace std;
-
-void ITransitionScript::frame_update(crepe::duration_t delta_time){
- if(this->transition)
- {
- // cout << "transition:" << velocity << std::endl;
- Transform & cam = this->get_components_by_name<Transform>(MainMenuConfig::CAMERA_NAME).front();
- RefVector<Transform> info_tf = this->get_components_by_tag<Transform>(MainMenuConfig::MENU_INFO_TAG);
- for (Transform & tf : info_tf) {
- tf.position.y -= MainMenuConfig::VELOCITY_INFO_UP * delta_time.count();
- }
- if(velocity < MainMenuConfig::VELOCITY_MAX && cam.position.x < MainMenuConfig::SLOW_DOWN) velocity += MainMenuConfig::VELOCITY_STEP * delta_time.count();
- else if(velocity > 20) velocity -= MainMenuConfig::VELOCITY_STEP * delta_time.count();
- if(cam.position.x < MainMenuConfig::END) cam.position.x += (velocity * delta_time.count());
- if(cam.position.x >= MainMenuConfig::END)
- {
- this->set_next_scene(this->get_scene_name());
- }
-
- }
-}
-
diff --git a/game/mainmenu/MainMenuConfig.h b/game/mainmenu/MainMenuConfig.h
deleted file mode 100644
index 3cc330c..0000000
--- a/game/mainmenu/MainMenuConfig.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-#include "types.h"
-#include <string>
-
-
-struct MainMenuConfig {
- //generic menu config
- static constexpr unsigned int STARTING_SORTING_IN_LAYER = 7;
- static constexpr const char* CAMERA_NAME = "camera";
- //main menu config
- static constexpr float STARTMAP_OFFSET = 50;
- static constexpr crepe::vec2 MENU_OFFSET = {0,0};
- static constexpr float MENU_BUTTON_SPACING = 10;
- static constexpr const char* MENU_BUTTON_NAME = "menu_button_background";
- static constexpr crepe::vec2 MENU_OFFSET_BUTTON = {-400,-200};
- static constexpr crepe::vec2 MENU_OFFSET_BUTTON_BACKGROUND = {-400,0};
- static constexpr const char* MENU_INFO_TAG = "menu_info";
- static constexpr crepe::vec2 MENU_OFFSET_INFO = {350,-365};
- static constexpr crepe::vec2 MENU_OFFSET_INFO_BACKGROUND = {350,-365}; //375
- //Scene names
- static constexpr const char* START_SCENE = "scene1";
- static constexpr const char* PREVIEW_SCENE = "scene1";
- static constexpr const char* SHOP_SCENE = "shopmenu";
- static constexpr const char* MAINMENU_SCENE = "mainmenu";
- //Moving to new scene (Start and Preview)
- static constexpr float SLOW_DOWN = 200;
- static constexpr float END = 300;
- static constexpr float VELOCITY_MAX = 200;
- static constexpr float VELOCITY_STEP = 200;
- static constexpr float VELOCITY_INFO_UP = 40;
- //button config
- static constexpr crepe::vec2 LARGE_OVERLAY_SIZE = {250,100};
- static constexpr crepe::vec2 SMALL_OVERLAY_SIZE_RIGHT = {150,100};
- static constexpr crepe::vec2 SMALL_OVERLAY_SIZE_LEFT = {50,100};
- static constexpr crepe::vec2 SIDE_PANEL_SIZE = {50,150};
- static constexpr crepe::vec2 ICON_SIZE = {50,50};
-
-};
-
diff --git a/game/mainmenu/BannerSubScene.cpp b/game/menus/BannerSubScene.cpp
index 0659d96..638b330 100644
--- a/game/mainmenu/BannerSubScene.cpp
+++ b/game/menus/BannerSubScene.cpp
@@ -1,5 +1,5 @@
#include "BannerSubScene.h"
-#include "MainMenuConfig.h"
+#include "MenusConfig.h"
#include "../Config.h"
@@ -15,20 +15,20 @@ void BannerSubScene::create(Scene & scn,const Data & data){
menu_banner.add_component<Sprite>(
Asset("asset/ui/settings_container/top_middle_setting.png"),
Sprite::Data{
- .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1,
+ .sorting_in_layer = STARTING_SORTING_IN_LAYER+1,
.size = {1100,88},
});
menu_banner.add_component<Sprite>(
Asset("asset/ui/settings_container/top_2_middle_setting.png"),
Sprite::Data{
- .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1,
+ .sorting_in_layer = STARTING_SORTING_IN_LAYER+1,
.size = {1100,66},
.position_offset {0,77},
});
menu_banner.add_component<Sprite>(
Asset("asset/ui/settings_container/banner_bottom.png"),
Sprite::Data{
- .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1,
+ .sorting_in_layer = STARTING_SORTING_IN_LAYER+1,
.size = {1100,7},
.position_offset {0,113},
});
diff --git a/game/mainmenu/BannerSubScene.h b/game/menus/BannerSubScene.h
index 341943d..341943d 100644
--- a/game/mainmenu/BannerSubScene.h
+++ b/game/menus/BannerSubScene.h
diff --git a/game/mainmenu/ButtonSetMainMenuScript.cpp b/game/menus/ButtonSetMainMenuScript.cpp
index 808d8a2..74773a0 100644
--- a/game/mainmenu/ButtonSetMainMenuScript.cpp
+++ b/game/menus/ButtonSetMainMenuScript.cpp
@@ -1,5 +1,5 @@
#include "ButtonSetMainMenuScript.h"
-#include "MainMenuConfig.h"
+#include "MenusConfig.h"
#include "iostream"
using namespace crepe;
@@ -12,7 +12,7 @@ void ButtonSetMainMenuScript::init(){
}
bool ButtonSetMainMenuScript::on_button_press(const ButtonPressEvent& e){
- this->set_next_scene(MainMenuConfig::MAINMENU_SCENE);
+ this->set_next_scene(MAINMENU_SCENE);
cout << "Start triggered:" << e.metadata.game_object_id << std::endl;
return false;
}
diff --git a/game/mainmenu/ButtonSetMainMenuScript.h b/game/menus/ButtonSetMainMenuScript.h
index 44c21aa..44c21aa 100644
--- a/game/mainmenu/ButtonSetMainMenuScript.h
+++ b/game/menus/ButtonSetMainMenuScript.h
diff --git a/game/mainmenu/ButtonSetShopScript.cpp b/game/menus/ButtonSetShopScript.cpp
index 0c855ec..035419f 100644
--- a/game/mainmenu/ButtonSetShopScript.cpp
+++ b/game/menus/ButtonSetShopScript.cpp
@@ -1,6 +1,6 @@
#include "ButtonSetShopScript.h"
-#include "MainMenuConfig.h"
#include "iostream"
+#include "MenusConfig.h"
using namespace crepe;
using namespace std;
@@ -12,7 +12,7 @@ void ButtonSetShopScript::init(){
}
bool ButtonSetShopScript::on_button_press(const ButtonPressEvent& e){
- this->set_next_scene(MainMenuConfig::SHOP_SCENE);
+ this->set_next_scene(SHOP_SCENE);
cout << "Start triggered:" << e.metadata.game_object_id << std::endl;
return false;
}
diff --git a/game/mainmenu/ButtonSetShopScript.h b/game/menus/ButtonSetShopScript.h
index 51db928..51db928 100644
--- a/game/mainmenu/ButtonSetShopScript.h
+++ b/game/menus/ButtonSetShopScript.h
diff --git a/game/mainmenu/ButtonSubScene.cpp b/game/menus/ButtonSubScene.cpp
index 760fc0d..3d68657 100644
--- a/game/mainmenu/ButtonSubScene.cpp
+++ b/game/menus/ButtonSubScene.cpp
@@ -1,11 +1,11 @@
#include "ButtonSubScene.h"
#include "ButtonSetMainMenuScript.h"
#include "ButtonSetShopScript.h"
-#include "ButtonTransitionPreviewScript.h"
+#include "mainmenu/ButtonTransitionPreviewScript.h"
#include "IButtonScript.h"
-#include "MainMenuConfig.h"
#include "../Config.h"
#include "api/Color.h"
+#include "MenusConfig.h"
#include <crepe/api/BehaviorScript.h>
#include <crepe/api/Sprite.h>
@@ -54,16 +54,16 @@ void ButtonSubScene::set_icon(crepe::GameObject & button_object,const Data & dat
switch (data.icon_type) {
case IconSelect::SHOP:
button_object.add_component<Sprite>(Asset("asset/ui/buttonCoinsSmall.png"),Sprite::Data{
- .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+3,
- .size = MainMenuConfig::ICON_SIZE,
+ .sorting_in_layer = STARTING_SORTING_IN_LAYER+3,
+ .size = ICON_SIZE,
.position_offset = data.icon_offset,
.world_space = data.worldspace,
});
break;
case IconSelect::COINS:
button_object.add_component<Sprite>(Asset("asset/ui/buttonCoinsSmall.png"),Sprite::Data{
- .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+3,
- .size = MainMenuConfig::ICON_SIZE,
+ .sorting_in_layer = STARTING_SORTING_IN_LAYER+3,
+ .size = ICON_SIZE,
.position_offset = data.icon_offset,
.world_space = data.worldspace,
});
@@ -86,42 +86,42 @@ void ButtonSubScene::set_button_overlay(crepe::GameObject & button_object,const
void ButtonSubScene::large_btn_overlay(crepe::GameObject & button_object,const Data & data){
button_object.add_component<Sprite>(Asset("asset/ui/buttonBacking.png"),Sprite::Data{
- .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1,
- .size = MainMenuConfig::LARGE_OVERLAY_SIZE,
+ .sorting_in_layer = STARTING_SORTING_IN_LAYER+1,
+ .size = LARGE_OVERLAY_SIZE,
.world_space = data.worldspace,
});
- button_object.add_component<Button>(MainMenuConfig::LARGE_OVERLAY_SIZE,Button::Data{});
+ button_object.add_component<Button>(LARGE_OVERLAY_SIZE,Button::Data{});
if(!data.color_side) return;
this->btn_color_side(button_object,SIDE_PANEL_OFFSET,data);
}
void ButtonSubScene::small_btn_overlay(crepe::GameObject & button_object,const Data & data){
button_object.add_component<Sprite>(Asset("asset/ui/backbuttonright.png"),Sprite::Data{
- .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1,
- .size = MainMenuConfig::SMALL_OVERLAY_SIZE_RIGHT,
+ .sorting_in_layer = STARTING_SORTING_IN_LAYER+1,
+ .size = SMALL_OVERLAY_SIZE_RIGHT,
.position_offset = {20,0},
.world_space = data.worldspace,
});
button_object.add_component<Sprite>(Asset("asset/ui/backbuttonleft.png"),Sprite::Data{
- .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1,
- .size = MainMenuConfig::SMALL_OVERLAY_SIZE_LEFT,
+ .sorting_in_layer = STARTING_SORTING_IN_LAYER+1,
+ .size = SMALL_OVERLAY_SIZE_LEFT,
.position_offset = {-80,0},
.world_space = data.worldspace,
});
- button_object.add_component<Button>(vec2{MainMenuConfig::SMALL_OVERLAY_SIZE_LEFT.x+MainMenuConfig::SMALL_OVERLAY_SIZE_RIGHT.x,MainMenuConfig::SMALL_OVERLAY_SIZE_LEFT.y},Button::Data{});
+ button_object.add_component<Button>(vec2{SMALL_OVERLAY_SIZE_LEFT.x+SMALL_OVERLAY_SIZE_RIGHT.x,SMALL_OVERLAY_SIZE_LEFT.y},Button::Data{});
}
void ButtonSubScene::btn_color_side(crepe::GameObject & button_object,const vec2 & offset,const Data & data){
button_object.add_component<Sprite>(Asset("asset/ui/buttonSmallBlue.png"),Sprite::Data{
- .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+2,
- .size = MainMenuConfig::SIDE_PANEL_SIZE,
+ .sorting_in_layer = STARTING_SORTING_IN_LAYER+2,
+ .size = SIDE_PANEL_SIZE,
.position_offset = offset,
.world_space = data.worldspace,
});
button_object.add_component<Sprite>(Asset("asset/ui/buttonSmallBlue.png"),Sprite::Data{
.flip = {true,false},
- .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+2,
- .size = MainMenuConfig::SIDE_PANEL_SIZE,
+ .sorting_in_layer = STARTING_SORTING_IN_LAYER+2,
+ .size = SIDE_PANEL_SIZE,
.position_offset = {-offset.x,offset.y},
.world_space = data.worldspace,
});
diff --git a/game/mainmenu/ButtonSubScene.h b/game/menus/ButtonSubScene.h
index 843dbcd..06006ac 100644
--- a/game/mainmenu/ButtonSubScene.h
+++ b/game/menus/ButtonSubScene.h
@@ -2,7 +2,6 @@
#include <crepe/api/GameObject.h>
#include <string>
-#include "MainMenuConfig.h"
namespace crepe {
class Scene;
diff --git a/game/mainmenu/IButtonScript.cpp b/game/menus/IButtonScript.cpp
index ab907c4..ab907c4 100644
--- a/game/mainmenu/IButtonScript.cpp
+++ b/game/menus/IButtonScript.cpp
diff --git a/game/mainmenu/IButtonScript.h b/game/menus/IButtonScript.h
index 10b57bf..10b57bf 100644
--- a/game/mainmenu/IButtonScript.h
+++ b/game/menus/IButtonScript.h
diff --git a/game/menus/MenusConfig.h b/game/menus/MenusConfig.h
new file mode 100644
index 0000000..692a4d2
--- /dev/null
+++ b/game/menus/MenusConfig.h
@@ -0,0 +1,18 @@
+#pragma once
+#include "types.h"
+
+
+//generic menu config
+static constexpr unsigned int STARTING_SORTING_IN_LAYER = 7;
+static constexpr const char* CAMERA_NAME = "camera";
+//Scene names
+static constexpr const char* START_SCENE = "scene1";
+static constexpr const char* PREVIEW_SCENE = "scene1";
+static constexpr const char* SHOP_SCENE = "shopmenu";
+static constexpr const char* MAINMENU_SCENE = "mainmenu";
+//button config
+static constexpr crepe::vec2 LARGE_OVERLAY_SIZE = {250,100};
+static constexpr crepe::vec2 SMALL_OVERLAY_SIZE_RIGHT = {150,100};
+static constexpr crepe::vec2 SMALL_OVERLAY_SIZE_LEFT = {50,100};
+static constexpr crepe::vec2 SIDE_PANEL_SIZE = {50,150};
+static constexpr crepe::vec2 ICON_SIZE = {50,50};
diff --git a/game/mainmenu/ButtonTransitionPreviewScript.cpp b/game/menus/mainmenu/ButtonTransitionPreviewScript.cpp
index d73c0f3..c702260 100644
--- a/game/mainmenu/ButtonTransitionPreviewScript.cpp
+++ b/game/menus/mainmenu/ButtonTransitionPreviewScript.cpp
@@ -1,5 +1,5 @@
#include "ButtonTransitionPreviewScript.h"
-#include "MainMenuConfig.h"
+#include "../MenusConfig.h"
#include "iostream"
using namespace crepe;
@@ -20,5 +20,5 @@ bool ButtonTransitionPreviewScript::on_button_press(const ButtonPressEvent& e){
const char* ButtonTransitionPreviewScript::get_scene_name() const {
// Provide the next scene defined in MainMenuConfig
- return MainMenuConfig::PREVIEW_SCENE;
+ return PREVIEW_SCENE;
}
diff --git a/game/mainmenu/ButtonTransitionPreviewScript.h b/game/menus/mainmenu/ButtonTransitionPreviewScript.h
index 4e5e6c9..26a778a 100644
--- a/game/mainmenu/ButtonTransitionPreviewScript.h
+++ b/game/menus/mainmenu/ButtonTransitionPreviewScript.h
@@ -1,6 +1,6 @@
#pragma once
-#include "IButtonScript.h"
+#include "../IButtonScript.h"
#include "ITransitionScript.h"
class ButtonTransitionPreviewScript : public ITransitionScript, public IButtonScript {
diff --git a/game/menus/mainmenu/ITransitionScript.cpp b/game/menus/mainmenu/ITransitionScript.cpp
new file mode 100644
index 0000000..07360a0
--- /dev/null
+++ b/game/menus/mainmenu/ITransitionScript.cpp
@@ -0,0 +1,30 @@
+#include "ITransitionScript.h"
+#include "api/Transform.h"
+#include <crepe/api/Camera.h>
+#include "MainMenuConfig.h"
+#include "../MenusConfig.h"
+#include "types.h"
+
+using namespace crepe;
+using namespace std;
+
+void ITransitionScript::frame_update(crepe::duration_t delta_time){
+ if(this->transition)
+ {
+ // cout << "transition:" << velocity << std::endl;
+ Transform & cam = this->get_components_by_name<Transform>(CAMERA_NAME).front();
+ RefVector<Transform> info_tf = this->get_components_by_tag<Transform>(MENU_INFO_TAG);
+ for (Transform & tf : info_tf) {
+ tf.position.y -= VELOCITY_INFO_UP * delta_time.count();
+ }
+ if(velocity < VELOCITY_MAX && cam.position.x < SLOW_DOWN) velocity += VELOCITY_STEP * delta_time.count();
+ else if(velocity > 20) velocity -= VELOCITY_STEP * delta_time.count();
+ if(cam.position.x < END) cam.position.x += (velocity * delta_time.count());
+ if(cam.position.x >= END)
+ {
+ this->set_next_scene(this->get_scene_name());
+ }
+
+ }
+}
+
diff --git a/game/mainmenu/ITransitionScript.h b/game/menus/mainmenu/ITransitionScript.h
index 78f1016..78f1016 100644
--- a/game/mainmenu/ITransitionScript.h
+++ b/game/menus/mainmenu/ITransitionScript.h
diff --git a/game/menus/mainmenu/MainMenuConfig.h b/game/menus/mainmenu/MainMenuConfig.h
new file mode 100644
index 0000000..7227f84
--- /dev/null
+++ b/game/menus/mainmenu/MainMenuConfig.h
@@ -0,0 +1,22 @@
+#pragma once
+#include "types.h"
+
+//main menu config
+static constexpr float STARTMAP_OFFSET = 50;
+static constexpr crepe::vec2 MENU_OFFSET = {0,0};
+static constexpr float MENU_BUTTON_SPACING = 10;
+static constexpr const char* MENU_BUTTON_NAME = "menu_button_background";
+static constexpr crepe::vec2 MENU_OFFSET_BUTTON = {-400,-200};
+static constexpr crepe::vec2 MENU_OFFSET_BUTTON_BACKGROUND = {-400,0};
+static constexpr const char* MENU_INFO_TAG = "menu_info";
+static constexpr crepe::vec2 MENU_OFFSET_INFO = {350,-365};
+static constexpr crepe::vec2 MENU_OFFSET_INFO_BACKGROUND = {350,-365}; //375
+//Moving to new scene (Start and Preview)
+static constexpr float SLOW_DOWN = 200;
+static constexpr float END = 300;
+static constexpr float VELOCITY_MAX = 200;
+static constexpr float VELOCITY_STEP = 200;
+static constexpr float VELOCITY_INFO_UP = 40;
+
+
+
diff --git a/game/mainmenu/MainMenuScene.cpp b/game/menus/mainmenu/MainMenuScene.cpp
index f720ffc..f6f8220 100644
--- a/game/mainmenu/MainMenuScene.cpp
+++ b/game/menus/mainmenu/MainMenuScene.cpp
@@ -1,16 +1,17 @@
#include "MainMenuScene.h"
-#include "ButtonSubScene.h"
+#include "../ButtonSubScene.h"
#include "TransitionStartScript.h"
#include "api/BehaviorScript.h"
#include "api/Camera.h"
-#include "../background/StartSubScene.h"
-#include "../background/HallwaySubScene.h"
+#include "../../background/StartSubScene.h"
+#include "../../background/HallwaySubScene.h"
#include "MainMenuConfig.h"
#include "api/GameObject.h"
#include "api/Sprite.h"
#include "manager/SaveManager.h"
-#include "../Config.h"
+#include "../../Config.h"
+#include "../MenusConfig.h"
using namespace crepe;
using namespace std;
@@ -18,7 +19,7 @@ using namespace std;
void MainMenuScene::load_scene(){
ButtonSubScene button;
- GameObject camera_object = this->new_object(MainMenuConfig::CAMERA_NAME);
+ GameObject camera_object = this->new_object(CAMERA_NAME);
camera_object.add_component<Camera>(ivec2(990, 720), vec2(1100, 800),
Camera::Data{
.bg_color = Color::RED,
@@ -27,16 +28,16 @@ void MainMenuScene::load_scene(){
//Button menu
- GameObject menu_button = this->new_object(MainMenuConfig::MENU_BUTTON_NAME,MainMenuConfig::MENU_BUTTON_NAME,MainMenuConfig::MENU_OFFSET);
+ GameObject menu_button = this->new_object(MENU_BUTTON_NAME,MENU_BUTTON_NAME,MENU_OFFSET);
menu_button.add_component<Sprite>(
Asset("asset/ui/background.png"),
Sprite::Data{
- .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+0,
+ .sorting_in_layer = STARTING_SORTING_IN_LAYER+0,
.size = {300,860},
- .position_offset = MainMenuConfig::MENU_OFFSET_BUTTON_BACKGROUND,
+ .position_offset = MENU_OFFSET_BUTTON_BACKGROUND,
});
- vec2 pos_btn = MainMenuConfig::MENU_OFFSET_BUTTON;
+ vec2 pos_btn = MENU_OFFSET_BUTTON;
//Preview btn
button.create(*this,ButtonSubScene::Data{
@@ -47,7 +48,7 @@ void MainMenuScene::load_scene(){
});
//Shop btn
- pos_btn.y += MainMenuConfig::MENU_BUTTON_SPACING + MainMenuConfig::LARGE_OVERLAY_SIZE.y;
+ pos_btn.y += MENU_BUTTON_SPACING + LARGE_OVERLAY_SIZE.y;
button.create(*this,ButtonSubScene::Data{
.text = "SHOP",
.text_offset = {-20,0},
@@ -61,18 +62,18 @@ void MainMenuScene::load_scene(){
//Start of map
StartSubScene start;
HallwaySubScene hallway;
- float begin_x = start.create(*this, MainMenuConfig::STARTMAP_OFFSET);
+ float begin_x = start.create(*this, STARTMAP_OFFSET);
begin_x = hallway.create(*this, begin_x, 1, Color::YELLOW);
//INFO menu
- GameObject menu_info = this->new_object("MENU_INFO_BACKGROUND",MainMenuConfig::MENU_INFO_TAG,MainMenuConfig::MENU_OFFSET);
+ GameObject menu_info = this->new_object("MENU_INFO_BACKGROUND",MENU_INFO_TAG,MENU_OFFSET);
menu_info.add_component<Sprite>(
Asset("asset/ui/itemsButtonBlankDark.png"),
Sprite::Data{
- .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+0,
+ .sorting_in_layer = STARTING_SORTING_IN_LAYER+0,
.size = {250,80},
- .position_offset = MainMenuConfig::MENU_OFFSET_INFO,
+ .position_offset = MENU_OFFSET_INFO,
.world_space = false,
});
SaveManager & savemgr = this->get_save_manager();
@@ -85,12 +86,12 @@ void MainMenuScene::load_scene(){
.text_width = amount_number*20,
.icon_offset = {60,0},
.icon_type = ButtonSubScene::IconSelect::COINS,
- .position = MainMenuConfig::MENU_OFFSET_INFO,
+ .position = MENU_OFFSET_INFO,
.script_type = ButtonSubScene::ScriptSelect::SHOP,
.scale = 0.6,
.worldspace = false,
.color_side = false,
- .tag = MainMenuConfig::MENU_INFO_TAG,
+ .tag = MENU_INFO_TAG,
});
}
diff --git a/game/mainmenu/MainMenuScene.h b/game/menus/mainmenu/MainMenuScene.h
index f7319cb..f7319cb 100644
--- a/game/mainmenu/MainMenuScene.h
+++ b/game/menus/mainmenu/MainMenuScene.h
diff --git a/game/mainmenu/TransitionStartScript.cpp b/game/menus/mainmenu/TransitionStartScript.cpp
index 5528bf9..d03adf0 100644
--- a/game/mainmenu/TransitionStartScript.cpp
+++ b/game/menus/mainmenu/TransitionStartScript.cpp
@@ -1,6 +1,5 @@
#include "TransitionStartScript.h"
-#include "MainMenuConfig.h"
-#include "api/Event.h"
+#include "../MenusConfig.h"
#include "iostream"
using namespace crepe;
@@ -17,5 +16,5 @@ void TransitionStartScript::fixed_update(crepe::duration_t dt){
const char* TransitionStartScript::get_scene_name() const {
// Provide the next scene defined in MainMenuConfig
- return MainMenuConfig::START_SCENE;
+ return START_SCENE;
}
diff --git a/game/mainmenu/TransitionStartScript.h b/game/menus/mainmenu/TransitionStartScript.h
index 76f532e..76f532e 100644
--- a/game/mainmenu/TransitionStartScript.h
+++ b/game/menus/mainmenu/TransitionStartScript.h
diff --git a/game/mainmenu/ShopMenuScene.cpp b/game/menus/shop/ShopMenuScene.cpp
index d6ad870..c0a5a72 100644
--- a/game/mainmenu/ShopMenuScene.cpp
+++ b/game/menus/shop/ShopMenuScene.cpp
@@ -1,16 +1,16 @@
#include "ShopMenuScene.h"
-#include "ButtonSubScene.h"
+#include "../ButtonSubScene.h"
#include "api/Camera.h"
-#include "MainMenuConfig.h"
+#include "../MenusConfig.h"
#include "api/Sprite.h"
-#include "BannerSubScene.h"
+#include "../BannerSubScene.h"
using namespace crepe;
using namespace std;
void ShopMenuScene::load_scene(){
- GameObject camera_object = this->new_object(MainMenuConfig::CAMERA_NAME);
+ GameObject camera_object = this->new_object(CAMERA_NAME);
camera_object.add_component<Camera>(ivec2(990, 720), vec2(1100, 800),
Camera::Data{
.bg_color = Color::RED,
@@ -25,7 +25,7 @@ void ShopMenuScene::load_scene(){
menu_background.add_component<Sprite>(
Asset("asset/ui/background.png"),
Sprite::Data{
- .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+0,
+ .sorting_in_layer = STARTING_SORTING_IN_LAYER+0,
.size = {1100,860},
.position_offset {0},
});
diff --git a/game/mainmenu/ShopMenuScene.h b/game/menus/shop/ShopMenuScene.h
index 7178372..7178372 100644
--- a/game/mainmenu/ShopMenuScene.h
+++ b/game/menus/shop/ShopMenuScene.h