aboutsummaryrefslogtreecommitdiff
path: root/game/hud/HudScript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'game/hud/HudScript.cpp')
-rw-r--r--game/hud/HudScript.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/game/hud/HudScript.cpp b/game/hud/HudScript.cpp
index d7a043a..30a5c15 100644
--- a/game/hud/HudScript.cpp
+++ b/game/hud/HudScript.cpp
@@ -19,19 +19,21 @@ void HudScript::init() {
txt.offset = TOP_LEFT+FONTOFFSET+BEST_OFFSET + vec2{record.size() * BEST_CHAR_WIDTH/2,0};
this->subscribe<GetCoinEvent>([this](const GetCoinEvent e)-> bool { return this->get_coin(e); });
- this->subscribe<KeyPressEvent>([this](const KeyPressEvent & ev) -> bool {
- if(ev.key != Keycode::END) return false;
- Text & txt_fps = this->get_components_by_name<Text>(HUD_FPS).front();
- this->show_fps = !this->show_fps;
- if(this->show_fps)
- {
- txt_fps.active = true;
- }
- else {
- txt_fps.active = false;
- }
- return true;
- });
+ this->subscribe<KeyPressEvent>([this](const KeyPressEvent & ev) -> bool { return this->toggle_fps(ev);});
+}
+
+bool HudScript::toggle_fps(crepe::KeyPressEvent ev){
+ if(ev.key != Keycode::END) return false;
+ Text & txt_fps = this->get_components_by_name<Text>(HUD_FPS).front();
+ this->show_fps = !this->show_fps;
+ if(this->show_fps)
+ {
+ txt_fps.active = true;
+ }
+ else {
+ txt_fps.active = false;
+ }
+ return true;
}
void HudScript::frame_update(crepe::duration_t dt) {