diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2025-01-07 14:06:45 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2025-01-07 14:06:45 +0100 |
commit | 41f890863706ee8ede43021fe83b776b638a18b7 (patch) | |
tree | 4ee74df7e60c8c22c61a1748dd648dda2783b21f /game/hud/HudScript.cpp | |
parent | bc66e7195c80facca244f933b882011e5e81fa3c (diff) |
fixed coins and improved coin
Diffstat (limited to 'game/hud/HudScript.cpp')
-rw-r--r-- | game/hud/HudScript.cpp | 28 |
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) { |