diff options
Diffstat (limited to 'game/hud')
-rw-r--r-- | game/hud/HudScript.cpp | 5 | ||||
-rw-r--r-- | game/hud/HudSubScene.cpp | 2 | ||||
-rw-r--r-- | game/hud/SpeedScript.cpp | 8 | ||||
-rw-r--r-- | game/hud/SpeedScript.h | 2 |
4 files changed, 14 insertions, 3 deletions
diff --git a/game/hud/HudScript.cpp b/game/hud/HudScript.cpp index 8f77706..e4aeae7 100644 --- a/game/hud/HudScript.cpp +++ b/game/hud/HudScript.cpp @@ -3,6 +3,8 @@ #include "../Config.h" #include "../Events.h" +#include "api/KeyCodes.h" +#include "menus/endgame/EndGameSubScript.h" #include <climits> @@ -36,7 +38,7 @@ void HudScript::init() { } bool HudScript::toggle_fps(crepe::KeyPressEvent ev) { - if (ev.key != Keycode::END) return false; + if (ev.key != Keycode::D1) return false; Text & txt_fps = this->get_components_by_name<Text>(HUD_FPS).front(); this->show_fps = !this->show_fps; if (this->show_fps) { @@ -91,5 +93,6 @@ bool HudScript::save() { SaveManager & savemgr = this->get_save_manager(); savemgr.set(TOTAL_COINS_RUN, this->coin_amount); savemgr.set(DISTANCE_RUN, this->distance_st); + this->trigger_event<ShowScoreEvent>(); return false; } diff --git a/game/hud/HudSubScene.cpp b/game/hud/HudSubScene.cpp index ca81614..dcc07b4 100644 --- a/game/hud/HudSubScene.cpp +++ b/game/hud/HudSubScene.cpp @@ -45,7 +45,7 @@ void HudSubScene::create(Scene & scn) { size_coin, FONT, Text::Data { .world_space = false, - .text_color = Color::YELLOW, + .text_color = Color::GOLD, }, TOP_LEFT + FONTOFFSET + COINS_OFFSET + vec2 {COINS_LENGTH * COINS_CHAR_WIDTH / 2, 0}, COINS diff --git a/game/hud/SpeedScript.cpp b/game/hud/SpeedScript.cpp index d0a4dfe..2ced47a 100644 --- a/game/hud/SpeedScript.cpp +++ b/game/hud/SpeedScript.cpp @@ -1,5 +1,7 @@ #include "SpeedScript.h" +#include "../Events.h" +#include "api/BehaviorScript.h" #include <crepe/api/Event.h> #include <crepe/api/KeyCodes.h> #include <crepe/manager/LoopTimerManager.h> @@ -21,14 +23,20 @@ void SpeedScript::init() { return true; }); + this->subscribe<EndGameEvent>([this](const EndGameEvent e) { + this->get_component<BehaviorScript>().active = false; + return false; + }); } void SpeedScript::fixed_update(crepe::duration_t dt) { LoopTimerManager & lp = this->get_loop_timer(); if (this->get_key_state(Keycode::PAGE_UP)) { + if (lp.get_time_scale() >= 2) return; lp.set_time_scale(lp.get_time_scale() + 0.1); } if (this->get_key_state(Keycode::PAGE_DOWN)) { + if (lp.get_time_scale() <= 0.5) return; lp.set_time_scale(lp.get_time_scale() - 0.1); } } diff --git a/game/hud/SpeedScript.h b/game/hud/SpeedScript.h index 6c15a89..b40f7cc 100644 --- a/game/hud/SpeedScript.h +++ b/game/hud/SpeedScript.h @@ -10,6 +10,6 @@ public: private: crepe::SaveManager * savemgr; - bool toggle = true; + bool toggle = false; float timescale = 1; }; |