diff options
Diffstat (limited to 'game/hud/HudScript.cpp')
-rw-r--r-- | game/hud/HudScript.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/game/hud/HudScript.cpp b/game/hud/HudScript.cpp index deeea14..71c84a1 100644 --- a/game/hud/HudScript.cpp +++ b/game/hud/HudScript.cpp @@ -21,8 +21,6 @@ void HudScript::init() { void HudScript::frame_update(crepe::duration_t dt) { - // string number = std::to_string(savemgr->get<int>(DISTANCE_RUN,0).get()); - // Distance Text & txt_dt = this->get_components_by_name<Text>(HUD_DISTANCE).front(); Transform & tf = this->get_components_by_name<Transform>(PLAYER_NAME).front(); @@ -37,4 +35,15 @@ void HudScript::frame_update(crepe::duration_t dt) { txt_co.text = amount_of_coins; txt_co.dimensions = {COINS_CHAR_WIDTH*amount_of_coins.size(),(COINS_CHAR_WIDTH)*2}; txt_co.offset = TOP_LEFT+FONTOFFSET+COINS_OFFSET + vec2{amount_of_coins.size() * COINS_CHAR_WIDTH/2,0}; + + // FPS + Text & txt_fps = this->get_components_by_name<Text>(HUD_FPS).front(); + float fps = this->get_loop_timer().get_fps(); + string fps_amount = to_string(this->get_loop_timer().get_fps()); + txt_fps.text = fps_amount; + txt_fps.dimensions = {FPS_CHAR_WIDTH*fps_amount.size(),(FPS_CHAR_WIDTH)*2}; + txt_fps.offset = TOP_LEFT+FONTOFFSET+FPS_OFFSET + vec2{fps_amount.size() * FPS_CHAR_WIDTH/2,0}; + if(fps >= 30) txt_fps.data.text_color = Color::YELLOW; + if(fps >= 50) txt_fps.data.text_color = Color::GREEN; + if(fps < 30) txt_fps.data.text_color = Color::RED; } |