diff options
Diffstat (limited to 'game/menus')
-rw-r--r-- | game/menus/ButtonNextMainMenuSubScript.cpp | 2 | ||||
-rw-r--r-- | game/menus/ButtonReplaySubScript.cpp | 8 | ||||
-rw-r--r-- | game/menus/ButtonSubScene.cpp | 15 | ||||
-rw-r--r-- | game/menus/endgame/EndGameSubScene.cpp | 21 | ||||
-rw-r--r-- | game/menus/endgame/EndGameSubScript.cpp | 26 | ||||
-rw-r--r-- | game/menus/shop/ButtonBuySelectBubbleScript.cpp | 18 | ||||
-rw-r--r-- | game/menus/shop/ButtonBuySelectBulletScript.cpp | 18 | ||||
-rw-r--r-- | game/menus/shop/ShopLoadScript.cpp | 73 | ||||
-rw-r--r-- | game/menus/shop/ShopMenuScene.cpp | 21 | ||||
-rw-r--r-- | game/menus/shop/Shopconfig.h | 2 |
10 files changed, 103 insertions, 101 deletions
diff --git a/game/menus/ButtonNextMainMenuSubScript.cpp b/game/menus/ButtonNextMainMenuSubScript.cpp index 631b4d3..63a2777 100644 --- a/game/menus/ButtonNextMainMenuSubScript.cpp +++ b/game/menus/ButtonNextMainMenuSubScript.cpp @@ -27,7 +27,7 @@ bool ButtonNextMainMenuSubScript::on_button_press(const ButtonPressEvent & e) { for (AudioSource & audio : audios) { audio.stop(); } - + this->trigger_event<DeleteRecordingEvent>(); SaveManager & savemgr = this->get_save_manager(); diff --git a/game/menus/ButtonReplaySubScript.cpp b/game/menus/ButtonReplaySubScript.cpp index 55e718d..01cccbf 100644 --- a/game/menus/ButtonReplaySubScript.cpp +++ b/game/menus/ButtonReplaySubScript.cpp @@ -20,24 +20,24 @@ void ButtonReplaySubScript::init() { this->subscribe<DeleteRecordingEvent>([this](const DeleteRecordingEvent & e) { return this->delete_recording(); }); - if(DISABLE_REPLAY)return; + if (DISABLE_REPLAY) return; replay.record_start(); } bool ButtonReplaySubScript::on_button_press(const ButtonPressEvent & e) { - if(DISABLE_REPLAY)return false; + if (DISABLE_REPLAY) return false; replay.play(this->recording); return false; } bool ButtonReplaySubScript::set_recording() { - if(DISABLE_REPLAY)return false; + if (DISABLE_REPLAY) return false; this->recording = replay.record_end(); return false; } bool ButtonReplaySubScript::delete_recording() { - if(DISABLE_REPLAY)return false; + if (DISABLE_REPLAY) return false; replay.release(this->recording); return false; } diff --git a/game/menus/ButtonSubScene.cpp b/game/menus/ButtonSubScene.cpp index baf154c..1fe6b03 100644 --- a/game/menus/ButtonSubScene.cpp +++ b/game/menus/ButtonSubScene.cpp @@ -79,23 +79,22 @@ void ButtonSubScene::set_script(crepe::GameObject & button_object, const Data & .set_script<ButtonShowCreditsSubScript>(); break; case ScriptSelect::PREVIEW_REPLAY: - button_object.add_component<BehaviorScript>() - .set_script<PreviewReplaySubScript>(); + button_object.add_component<BehaviorScript>().set_script<PreviewReplaySubScript>(); break; case ScriptSelect::PREVIEW_START: - button_object.add_component<BehaviorScript>() - .set_script<PreviewStartRecSubScript>(); + button_object.add_component<BehaviorScript>().set_script<PreviewStartRecSubScript>( + ); break; case ScriptSelect::PREVIEW_STOP: - button_object.add_component<BehaviorScript>() - .set_script<PreviewStopRecSubScript>(); + button_object.add_component<BehaviorScript>().set_script<PreviewStopRecSubScript>( + ); break; case ScriptSelect::SHOP_BULLET: - button_object.add_component<BehaviorScript>() + button_object.add_component<BehaviorScript>() .set_script<ButtonBuySelectBulletScript>(); break; case ScriptSelect::SHOP_BUBBLE: - button_object.add_component<BehaviorScript>() + button_object.add_component<BehaviorScript>() .set_script<ButtonBuySelectBubbleScript>(); break; case ScriptSelect::NONE: diff --git a/game/menus/endgame/EndGameSubScene.cpp b/game/menus/endgame/EndGameSubScene.cpp index 0b72bdc..b33072a 100644 --- a/game/menus/endgame/EndGameSubScene.cpp +++ b/game/menus/endgame/EndGameSubScene.cpp @@ -73,21 +73,24 @@ void EndGameSubScene::create(Scene & scn) { .world_space = false, .text_color = Color::WHITE, }, - vec2 {0, Y_SPACING+Y_OFFSET} + FONTOFFSET, DISTANCE_STRING + vec2 {0, Y_SPACING + Y_OFFSET} + FONTOFFSET, DISTANCE_STRING ); // Highscore const string HIGHSCORE_STRING = "NEW HIGHSCORE"; GameObject highscore = scn.new_object("highscore_endgame", "highscore_tag_end"); crepe::vec2 size_highscore = {200, (200.0f / HIGHSCORE_STRING.size()) * 2}; - highscore.add_component<Text>( - size_highscore, FONT, - Text::Data { - .world_space = false, - .text_color = Color::WHITE, - }, - vec2 {0, Y_SPACING*2+Y_OFFSET} + FONTOFFSET, HIGHSCORE_STRING - ).active = false; + highscore + .add_component<Text>( + size_highscore, FONT, + Text::Data { + .world_space = false, + .text_color = Color::WHITE, + }, + vec2 {0, Y_SPACING * 2 + Y_OFFSET} + FONTOFFSET, HIGHSCORE_STRING + ) + .active + = false; // Buttons vec2 button_position = {190, 190}; diff --git a/game/menus/endgame/EndGameSubScript.cpp b/game/menus/endgame/EndGameSubScript.cpp index e081350..6793f3e 100644 --- a/game/menus/endgame/EndGameSubScript.cpp +++ b/game/menus/endgame/EndGameSubScript.cpp @@ -1,9 +1,9 @@ #include "EndGameSubScript.h" +#include "../../Config.h" #include "../../Events.h" #include "../ButtonReplaySubScript.h" #include "../IFloatingWindowScript.h" -#include "../../Config.h" #include "ValueBroker.h" #include "manager/SaveManager.h" @@ -60,11 +60,13 @@ bool EndGameSubScript::reset_timescale() { return false; } -bool EndGameSubScript::showscore(){ - // Gather text +bool EndGameSubScript::showscore() { + // Gather text Text & coins_text = this->get_components_by_name<Text>("gold_endgame").front().get(); - Text & distance_text = this->get_components_by_name<Text>("distance_endgame").front().get(); - Text & highscore_text = this->get_components_by_name<Text>("highscore_endgame").front().get(); + Text & distance_text + = this->get_components_by_name<Text>("distance_endgame").front().get(); + Text & highscore_text + = this->get_components_by_name<Text>("highscore_endgame").front().get(); highscore_text.active = false; // Gather saved data @@ -75,20 +77,24 @@ bool EndGameSubScript::showscore(){ int distance_game = savemgr.get<int>(DISTANCE_GAME, 0).get(); // Show highscore - if(distance_run > distance_game) highscore_text.active = true; + if (distance_run > distance_game) highscore_text.active = true; const float CHAR_SIZE_DIS = 20; // Show distance - std::string distance_string = "DISTANCE:" + distance.get(); + std::string distance_string = "DISTANCE:" + distance.get(); distance_text.text = distance_string; - crepe::vec2 size_distance = {CHAR_SIZE_DIS*distance_string.size(), (CHAR_SIZE_DIS*distance_string.size() / distance_string.size()) * 2}; + crepe::vec2 size_distance + = {CHAR_SIZE_DIS * distance_string.size(), + (CHAR_SIZE_DIS * distance_string.size() / distance_string.size()) * 2}; distance_text.dimensions = size_distance; const float CHAR_SIZE_COIN = 16; // Show coins - std::string coins_string = "Coins:" + coins.get(); + std::string coins_string = "Coins:" + coins.get(); coins_text.text = coins_string; - crepe::vec2 size_coins = {CHAR_SIZE_COIN*coins_string.size(), (CHAR_SIZE_COIN*coins_string.size() / coins_string.size()) * 2}; + crepe::vec2 size_coins + = {CHAR_SIZE_COIN * coins_string.size(), + (CHAR_SIZE_COIN * coins_string.size() / coins_string.size()) * 2}; coins_text.dimensions = size_coins; return false; diff --git a/game/menus/shop/ButtonBuySelectBubbleScript.cpp b/game/menus/shop/ButtonBuySelectBubbleScript.cpp index 21dbe1a..741afde 100644 --- a/game/menus/shop/ButtonBuySelectBubbleScript.cpp +++ b/game/menus/shop/ButtonBuySelectBubbleScript.cpp @@ -17,19 +17,17 @@ void ButtonBuySelectBubbleScript::init() { bool ButtonBuySelectBubbleScript::on_button_press(const ButtonPressEvent & e) { SaveManager & save = this->get_save_manager(); - ValueBroker<int> buy_bullet = save.get<int>(BUY_BUBBLE_SAVE,0); - if(!buy_bullet.get()){ - ValueBroker<int> coins = save.get<int>(TOTAL_COINS_GAME,0); - if(coins.get() >= 1000) - { + ValueBroker<int> buy_bullet = save.get<int>(BUY_BUBBLE_SAVE, 0); + if (!buy_bullet.get()) { + ValueBroker<int> coins = save.get<int>(TOTAL_COINS_GAME, 0); + if (coins.get() >= 1000) { int coin = coins.get(); coin -= 1000; - save.set(TOTAL_COINS_GAME,coin); - save.set(BUY_BUBBLE_SAVE,1); + save.set(TOTAL_COINS_GAME, coin); + save.set(BUY_BUBBLE_SAVE, 1); } - } - else { - save.set(JETPACK_PARTICLES,1); + } else { + save.set(JETPACK_PARTICLES, 1); } this->trigger_event<ShopUpdate>(); return false; diff --git a/game/menus/shop/ButtonBuySelectBulletScript.cpp b/game/menus/shop/ButtonBuySelectBulletScript.cpp index 71d8b76..d30849c 100644 --- a/game/menus/shop/ButtonBuySelectBulletScript.cpp +++ b/game/menus/shop/ButtonBuySelectBulletScript.cpp @@ -17,19 +17,17 @@ void ButtonBuySelectBulletScript::init() { bool ButtonBuySelectBulletScript::on_button_press(const ButtonPressEvent & e) { SaveManager & save = this->get_save_manager(); - ValueBroker<int> buy_bullet = save.get<int>(BUY_BULLET_SAVE,0); - if(!buy_bullet.get()){ - ValueBroker<int> coins = save.get<int>(TOTAL_COINS_GAME,0); - if(coins.get() >= 0) - { + ValueBroker<int> buy_bullet = save.get<int>(BUY_BULLET_SAVE, 0); + if (!buy_bullet.get()) { + ValueBroker<int> coins = save.get<int>(TOTAL_COINS_GAME, 0); + if (coins.get() >= 0) { int coin = coins.get(); coin -= 0; - save.set(TOTAL_COINS_GAME,coin); - save.set(BUY_BULLET_SAVE,1); + save.set(TOTAL_COINS_GAME, coin); + save.set(BUY_BULLET_SAVE, 1); } - } - else { - save.set(JETPACK_PARTICLES,0); + } else { + save.set(JETPACK_PARTICLES, 0); } this->trigger_event<ShopUpdate>(); return false; diff --git a/game/menus/shop/ShopLoadScript.cpp b/game/menus/shop/ShopLoadScript.cpp index a9f9bfe..a545fe2 100644 --- a/game/menus/shop/ShopLoadScript.cpp +++ b/game/menus/shop/ShopLoadScript.cpp @@ -1,129 +1,124 @@ #include "ShopLoadScript.h" -#include <crepe/ValueBroker.h> +#include "Shopconfig.h" #include "api/Button.h" #include "api/Sprite.h" -#include "Shopconfig.h" #include "api/Text.h" #include "manager/SaveManager.h" +#include <crepe/ValueBroker.h> using namespace crepe; using namespace std; void ShopLoadScript::init() { this->update(); - this->subscribe<ShopUpdate>([this](const ShopUpdate e) { - return this->update(); - }); + this->subscribe<ShopUpdate>([this](const ShopUpdate e) { return this->update(); }); } -bool ShopLoadScript::update(){ +bool ShopLoadScript::update() { SaveManager & save = this->get_save_manager(); - ValueBroker<int> buy_bullet = save.get<int>(BUY_BULLET_SAVE,0); - ValueBroker<int> buy_bubble = save.get<int>(BUY_BUBBLE_SAVE,0); + ValueBroker<int> buy_bullet = save.get<int>(BUY_BULLET_SAVE, 0); + ValueBroker<int> buy_bubble = save.get<int>(BUY_BUBBLE_SAVE, 0); - - if(buy_bullet.get()){ + if (buy_bullet.get()) { auto sprites = this->get_components_by_tag<Sprite>(BUY_BULLET); - for(auto sprite : sprites){ + for (auto sprite : sprites) { sprite.get().active = false; } auto buttons = this->get_components_by_tag<Button>(BUY_BULLET); - for(auto btn : buttons){ + for (auto btn : buttons) { btn.get().active = false; } auto texts = this->get_components_by_tag<Text>(BUY_BULLET); - for(auto txt : texts){ + for (auto txt : texts) { txt.get().active = false; } auto sprites1 = this->get_components_by_tag<Sprite>(SELECT_BULLET); - for(auto sprite : sprites1){ + for (auto sprite : sprites1) { sprite.get().active = true; } auto buttons1 = this->get_components_by_tag<Button>(SELECT_BULLET); - for(auto btn : buttons1){ + for (auto btn : buttons1) { btn.get().active = true; } auto texts1 = this->get_components_by_tag<Text>(SELECT_BULLET); - for(auto txt : texts1){ + for (auto txt : texts1) { txt.get().active = true; } - } - else { + } else { auto sprites = this->get_components_by_tag<Sprite>(SELECT_BULLET); - for(auto sprite : sprites){ + for (auto sprite : sprites) { sprite.get().active = false; } auto buttons = this->get_components_by_tag<Button>(SELECT_BULLET); - for(auto btn : buttons){ + for (auto btn : buttons) { btn.get().active = false; } auto texts = this->get_components_by_tag<Text>(SELECT_BULLET); - for(auto txt : texts){ + for (auto txt : texts) { txt.get().active = false; } auto sprites1 = this->get_components_by_tag<Sprite>(BUY_BULLET); - for(auto sprite : sprites1){ + for (auto sprite : sprites1) { sprite.get().active = true; } auto buttons1 = this->get_components_by_tag<Button>(BUY_BULLET); - for(auto btn : buttons1){ + for (auto btn : buttons1) { btn.get().active = true; } auto texts1 = this->get_components_by_tag<Text>(BUY_BULLET); - for(auto txt : texts1){ + for (auto txt : texts1) { txt.get().active = true; } } - if(buy_bubble.get()){ + if (buy_bubble.get()) { auto sprites = this->get_components_by_tag<Sprite>(BUY_BUBBLE); - for(auto sprite : sprites){ + for (auto sprite : sprites) { sprite.get().active = false; } auto buttons = this->get_components_by_tag<Button>(BUY_BUBBLE); - for(auto btn : buttons){ + for (auto btn : buttons) { btn.get().active = false; } auto texts = this->get_components_by_tag<Text>(BUY_BUBBLE); - for(auto txt : texts){ + for (auto txt : texts) { txt.get().active = false; } auto sprites1 = this->get_components_by_tag<Sprite>(SELECT_BUBBLE); - for(auto sprite : sprites1){ + for (auto sprite : sprites1) { sprite.get().active = true; } auto buttons1 = this->get_components_by_tag<Button>(SELECT_BUBBLE); - for(auto btn : buttons1){ + for (auto btn : buttons1) { btn.get().active = true; } auto texts1 = this->get_components_by_tag<Text>(SELECT_BUBBLE); - for(auto txt : texts1){ + for (auto txt : texts1) { txt.get().active = true; } - } - else { + } else { auto sprites = this->get_components_by_tag<Sprite>(SELECT_BUBBLE); - for(auto sprite : sprites){ + for (auto sprite : sprites) { sprite.get().active = false; } auto buttons = this->get_components_by_tag<Button>(SELECT_BUBBLE); - for(auto btn : buttons){ + for (auto btn : buttons) { btn.get().active = false; } auto texts = this->get_components_by_tag<Text>(SELECT_BUBBLE); - for(auto txt : texts){ + for (auto txt : texts) { txt.get().active = false; } auto sprites1 = this->get_components_by_tag<Sprite>(BUY_BUBBLE); - for(auto sprite : sprites1){ + for (auto sprite : sprites1) { sprite.get().active = true; } auto buttons1 = this->get_components_by_tag<Button>(BUY_BUBBLE); - for(auto btn : buttons1){ + for (auto btn : buttons1) { btn.get().active = true; } auto texts1 = this->get_components_by_tag<Text>(BUY_BUBBLE); - for(auto txt : texts1){ + for (auto txt : texts1) { txt.get().active = true; } } diff --git a/game/menus/shop/ShopMenuScene.cpp b/game/menus/shop/ShopMenuScene.cpp index fc7323b..641352c 100644 --- a/game/menus/shop/ShopMenuScene.cpp +++ b/game/menus/shop/ShopMenuScene.cpp @@ -9,10 +9,10 @@ #include "menus/shop/ShopLoadScript.h" #include "types.h" +#include "Shopconfig.h" #include <crepe/api/Camera.h> #include <crepe/api/Sprite.h> #include <crepe/api/Text.h> -#include "Shopconfig.h" using namespace crepe; using namespace std; @@ -58,8 +58,6 @@ void ShopMenuScene::load_scene() { } ); - - const float CHAR_SIZE = 16; const float CHAR_SIZE_COIN = 16; crepe::vec2 size; @@ -75,7 +73,9 @@ void ShopMenuScene::load_scene() { ); const string BULLETS_STRING = "BULLETS"; - size = {CHAR_SIZE*BULLETS_STRING.size(), (CHAR_SIZE*BULLETS_STRING.size() / BULLETS_STRING.size()) * 2}; + size + = {CHAR_SIZE * BULLETS_STRING.size(), + (CHAR_SIZE * BULLETS_STRING.size() / BULLETS_STRING.size()) * 2}; shop_item_bullet.add_component<Text>( size, FONT, @@ -95,7 +95,9 @@ void ShopMenuScene::load_scene() { ); const string BULLETS_GOLD_STRING = "0"; - size = {CHAR_SIZE_COIN*BULLETS_GOLD_STRING.size(), (CHAR_SIZE_COIN*BULLETS_GOLD_STRING.size() / BULLETS_GOLD_STRING.size()) * 2}; + size + = {CHAR_SIZE_COIN * BULLETS_GOLD_STRING.size(), + (CHAR_SIZE_COIN * BULLETS_GOLD_STRING.size() / BULLETS_GOLD_STRING.size()) * 2}; shop_item_bullet.add_component<Text>( size, FONT, Text::Data { @@ -116,7 +118,9 @@ void ShopMenuScene::load_scene() { ); const string BUBBLE_STRING = "BUBBLE"; - size = {CHAR_SIZE*BUBBLE_STRING.size(), (CHAR_SIZE*BUBBLE_STRING.size() / BUBBLE_STRING.size()) * 2}; + size + = {CHAR_SIZE * BUBBLE_STRING.size(), + (CHAR_SIZE * BUBBLE_STRING.size() / BUBBLE_STRING.size()) * 2}; shop_item_bubble.add_component<Text>( size, FONT, Text::Data { @@ -135,7 +139,9 @@ void ShopMenuScene::load_scene() { ); const string BUBBLE_GOLD_STRING = "1000"; - size = {CHAR_SIZE_COIN*BUBBLE_GOLD_STRING.size(), (CHAR_SIZE_COIN*BUBBLE_GOLD_STRING.size() / BUBBLE_GOLD_STRING.size()) * 2}; + size + = {CHAR_SIZE_COIN * BUBBLE_GOLD_STRING.size(), + (CHAR_SIZE_COIN * BUBBLE_GOLD_STRING.size() / BUBBLE_GOLD_STRING.size()) * 2}; shop_item_bubble.add_component<Text>( size, FONT, Text::Data { @@ -205,7 +211,6 @@ void ShopMenuScene::load_scene() { .btn_side_color = ButtonSubScene::ButtonSideColor::PURPLE } ); - } string ShopMenuScene::get_name() const { return SHOP_SCENE; } diff --git a/game/menus/shop/Shopconfig.h b/game/menus/shop/Shopconfig.h index 04c8c5c..a686242 100644 --- a/game/menus/shop/Shopconfig.h +++ b/game/menus/shop/Shopconfig.h @@ -7,10 +7,8 @@ static constexpr const char * SELECT_BULLET = "SELECT_BULLET"; static constexpr const char * BUY_BUBBLE = "BUY_BUBBLE"; static constexpr const char * SELECT_BUBBLE = "SELECT_BUBBLE"; - //save_data static constexpr const char * BUY_BULLET_SAVE = "BUY_BULLET_SAVE"; static constexpr const char * BUY_BUBBLE_SAVE = "BUY_BUBBLE_SAVE"; - struct ShopUpdate : public crepe::Event {}; |