diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2025-01-05 14:26:19 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2025-01-05 14:26:19 +0100 |
commit | ba170d00586ab261e015cc2febbb43f9aa7ae43e (patch) | |
tree | 4b902f20aa0b10a3ac04ec2c03f46ec3449558d1 /game/hud/HudScript.cpp | |
parent | 5ae4e3f0e3ff1d111eaea54b7b0a0788203d9d72 (diff) |
added hud
Diffstat (limited to 'game/hud/HudScript.cpp')
-rw-r--r-- | game/hud/HudScript.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/game/hud/HudScript.cpp b/game/hud/HudScript.cpp new file mode 100644 index 0000000..42ff118 --- /dev/null +++ b/game/hud/HudScript.cpp @@ -0,0 +1,33 @@ +#include "HudScript.h" +#include "api/Text.h" +#include "api/Transform.h" +#include "manager/SaveManager.h" +#include "../Config.h" +#include "HudConfig.h" + +using namespace crepe; +using namespace std; + +void HudScript::init() { + savemgr = &this->get_save_manager(); + savemgr->set(TOTAL_COINS_RUN,0); + Text & txt = this->get_components_by_name<Text>(HUD_BEST).front(); + string record = BEST+to_string(savemgr->get<int>(DISTANCE_GAME,0).get())+DISTANCE_UNIT; + txt.text = record; +} + +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(); + string distance = to_string(static_cast<int>(tf.position.x/STEP_SIZE_DISTANCE)) + DISTANCE_UNIT; + txt_dt.text = distance; + + // Coins + Text & txt_co = this->get_components_by_name<Text>(HUD_COINS).front(); + string amount_of_coins = to_string(savemgr->get<int>(TOTAL_COINS_RUN,0).get()); + txt_co.text = amount_of_coins; +} |