aboutsummaryrefslogtreecommitdiff
path: root/src/gunner/text.c
diff options
context:
space:
mode:
authorUneven Prankster <unevenprankster@protonmail.com>2023-11-16 21:12:27 -0300
committerUneven Prankster <unevenprankster@protonmail.com>2023-11-16 21:12:27 -0300
commit2bbf92ad5ae7708bf18ac7ef333e9a979d8d1bde (patch)
treec9d22bb0d73d9cc0c8586e4d31c93a561ea8e910 /src/gunner/text.c
parent1c0cc775732201f4c4d3ee0d6772be786b3b4aa1 (diff)
Working so hard like a soldiermain
Can't afford a thing on TV
Diffstat (limited to 'src/gunner/text.c')
-rw-r--r--src/gunner/text.c14
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)