diff --git a/code/game/src/renderer_v0.c b/code/game/src/renderer_v0.c index 4dc041e..41940fc 100644 --- a/code/game/src/renderer_v0.c +++ b/code/game/src/renderer_v0.c @@ -47,11 +47,11 @@ void DEBUG_draw_ground(uint64_t key, entity_view * data) { extern bool inv_is_open; void DEBUG_draw_entities(uint64_t key, entity_view * data) { - uint16_t size = 16; - uint16_t font_size = (uint16_t)lerp(4.0f, 32.0f, 0.5f/(float)render_camera.zoom); + float size = 16.f; + float font_size = lerp(4.0f, 32.0f, 0.5f/(float)render_camera.zoom); float font_spacing = 1.1f; float title_bg_offset = 4; - float fixed_title_offset = 8; + float fixed_title_offset = 8.f; switch (data->kind) { case EKIND_DEMO_NPC: { @@ -64,10 +64,10 @@ void DEBUG_draw_entities(uint64_t key, entity_view * data) { float y = data->y; float health = (data->hp / data->max_hp); const char *title = TextFormat("Player %d", key); - int title_w = MeasureTextEco(title, font_size, font_spacing); - DrawRectangleEco(x-title_w/2-title_bg_offset/2, y-size-font_size-fixed_title_offset, title_w+title_bg_offset, font_size, ColorAlpha(BLACK, data->tran_time)); - DrawRectangleEco(x-title_w/2-title_bg_offset/2, y-size-fixed_title_offset, title_w*health+title_bg_offset, font_size*0.2f, ColorAlpha(RED, data->tran_time)); - DrawTextEco(title, x-title_w/2, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(RAYWHITE, data->tran_time), font_spacing); + float title_w = MeasureTextEco(title, font_size, font_spacing); + DrawRectangleEco(x-title_w/2.f-title_bg_offset/2.f, y-size-font_size-fixed_title_offset, title_w+title_bg_offset, font_size, ColorAlpha(BLACK, data->tran_time)); + DrawRectangleEco(x-title_w/2.f-title_bg_offset/2.f, y-size-fixed_title_offset, title_w*health+title_bg_offset, font_size*0.2f, ColorAlpha(RED, data->tran_time)); + DrawTextEco(title, x-title_w/2.f, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(RAYWHITE, data->tran_time), font_spacing); DrawCircleEco(x, y, size, ColorAlpha(YELLOW, data->tran_time)); if (data->has_items && !data->inside_vehicle) { @@ -88,8 +88,8 @@ void DEBUG_draw_entities(uint64_t key, entity_view * data) { float y = data->y; const char *title = TextFormat("Bot %d", key); int title_w = MeasureTextEco(title, font_size, font_spacing); - DrawRectangleEco(x-title_w/2-title_bg_offset/2, y-size-font_size-fixed_title_offset, title_w+title_bg_offset, font_size, ColorAlpha(GRAY, data->tran_time)); - DrawTextEco(title, x-title_w/2, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(BLACK, data->tran_time), font_spacing); + DrawRectangleEco(x-title_w/2.f-title_bg_offset/2.f, y-size-font_size-fixed_title_offset, title_w+title_bg_offset, font_size, ColorAlpha(GRAY, data->tran_time)); + DrawTextEco(title, x-title_w/2.f, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(BLACK, data->tran_time), font_spacing); DrawCircleEco(x, y, size, ColorAlpha(PURPLE, data->tran_time)); }break; case EKIND_ITEM: { diff --git a/code/game/src/utils/raylib_helpers.h b/code/game/src/utils/raylib_helpers.h index 713c3fb..f6abd53 100644 --- a/code/game/src/utils/raylib_helpers.h +++ b/code/game/src/utils/raylib_helpers.h @@ -79,36 +79,36 @@ void DrawTextExEco(Font font, const char *text, Vector2 position, float fontSize } static inline -void DrawTextEco(const char *text, float posX, float posY, int fontSize, Color color, float spacing) { +void DrawTextEco(const char *text, float posX, float posY, float fontSize, Color color, float spacing) { #if 1 // Check if default font has been loaded if (GetFontDefault().texture.id != 0) { Vector2 position = { posX , posY }; float defaultFontSize = 10.0; // Default Font chars height in pixel - float new_spacing = spacing == 0.0f ? fontSize/(float)defaultFontSize : spacing; + float new_spacing = spacing == 0.0f ? fontSize/defaultFontSize : spacing; - DrawTextExEco(GetFontDefault(), text, position, (float)fontSize , (float)new_spacing , color); + DrawTextExEco(GetFontDefault(), text, position, fontSize , new_spacing , color); } #endif } static inline -int MeasureTextEco(const char *text, int fontSize, float spacing) { +float MeasureTextEco(const char *text, float fontSize, float spacing) { #if 1 Vector2 vec = { 0.0f, 0.0f }; // Check if default font has been loaded if (GetFontDefault().texture.id != 0) { float defaultFontSize = 10.0; // Default Font chars height in pixel - float new_spacing = spacing == 0.0f ? (float)fontSize/defaultFontSize : spacing; + float new_spacing = spacing == 0.0f ? fontSize/defaultFontSize : spacing; - vec = MeasureTextEx(GetFontDefault(), text, (float)fontSize, (float)new_spacing); + vec = MeasureTextEx(GetFontDefault(), text, fontSize, (float)new_spacing); } - return (int)vec.x; + return vec.x; #else - return 0; + return 0.f; #endif }