5 #include "./wiggly_text.h"
7 #include "system/stacktrace.h"
8 #include "system/nth_alloc.h"
9 #include "system/str.h"
10 #include "game/camera.h"
12 void wiggly_text_render(const WigglyText *wiggly_text,
16 trace_assert(wiggly_text);
19 const size_t n = strlen(wiggly_text->text);
22 for (size_t i = 0; i < n; ++i) {
23 buf[0] = wiggly_text->text[i];
25 camera_render_text_screen(
33 (float) (i * FONT_CHAR_WIDTH) * wiggly_text->scale.x,
34 sinf(wiggly_text->angle + (float) i / (float) n * 10.0f) * 20.0f)));
38 int wiggly_text_update(WigglyText *wiggly_text, float delta_time)
40 trace_assert(wiggly_text);
41 wiggly_text->angle = fmodf(wiggly_text->angle + 10.0f * delta_time, 2 * PI);
45 Vec2f wiggly_text_size(const WigglyText *wiggly_text)
47 trace_assert(wiggly_text);
49 const Rect boundary = sprite_font_boundary_box(
52 strlen(wiggly_text->text));
54 return vec(boundary.w, boundary.h);