diff options
Diffstat (limited to 'src/gunner/text.c')
| -rw-r--r-- | src/gunner/text.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/gunner/text.c b/src/gunner/text.c index 0812ff1..d7f1e23 100644 --- a/src/gunner/text.c +++ b/src/gunner/text.c @@ -94,10 +94,18 @@ i32 load_font(const char* path) return current_idx; } -void draw_text_font(i32 idx, const char* text, vec2 pos, i32 size, Color col) +void draw_text_font(i32 idx, const char* text, Vector2 pos, f32 size, Color col) { - Vector2 position = (Vector2){FROM_FIXED(pos.x), FROM_FIXED(pos.y)}; - DrawTextEx(font_slots[idx], text, position, (f32)size, 1.0f, col); + DrawTextEx(font_slots[idx], text, pos, size, 0.5f, col); +} + +void draw_text_font_centered(i32 idx, const char* text, f32 y_offset, f32 size, Color col) +{ + Vector2 vec = MeasureTextEx(font_slots[idx], text, size, 0.5f); + Vector2 final_pos = (Vector2){(320.0f - vec.x) / 2.f, y_offset}; + + DrawTextEx(font_slots[idx], text, final_pos, size, 0.5f, col); + DrawLineV((Vector2){final_pos.x, y_offset + vec.y - 2.f}, (Vector2){final_pos.x + vec.x, y_offset + vec.y - 2.f}, col); } void unload_font(i32 idx) |
