2 #include "game/level/background.h"
3 #include "game/sprite_font.h"
5 #include "system/nth_alloc.h"
6 #include "system/stacktrace.h"
7 #include "system/str.h"
8 #include "system/log.h"
9 #include "ui/wiggly_text.h"
12 #define TITLE_MARGIN_TOP 100.0f
17 Background background;
18 Vec2f camera_position;
19 WigglyText wiggly_text;
22 Credits *create_credits(void)
25 Credits *credits = PUSH_LT(
27 nth_calloc(1, sizeof(Credits)),
29 if (credits == NULL) {
34 credits->background = create_background(hexstr("250741"));
36 credits->camera_position = vec(0.0f, 0.0f);
38 credits->wiggly_text = (WigglyText) {
39 .text = "Twitch Subs/Contributors",
40 .scale = {8.0f, 8.0f},
47 void destroy_credits(Credits *credits)
49 trace_assert(credits);
50 RETURN_LT0(credits->lt);
53 int credits_render(const Credits *credits, const Camera *camera)
55 trace_assert(credits);
58 const Rect viewport = camera_view_port_screen(camera);
60 if (background_render(&credits->background, camera) < 0) {
64 const Vec2f title_size = wiggly_text_size(&credits->wiggly_text, camera);
66 if (wiggly_text_render(
67 &credits->wiggly_text,
69 vec(viewport.w * 0.5f - title_size.x * 0.5f, TITLE_MARGIN_TOP)) < 0) {
72 // TODO(#1150): Credits page don't display list of subs and contributors
76 int credits_update(Credits *credits, Camera *camera, float dt)
78 trace_assert(credits);
81 vec_add(&credits->camera_position,
82 vec(0.0f, 20.0f * dt));
83 camera_center_at(camera, credits->camera_position);
85 if (wiggly_text_update(&credits->wiggly_text, dt) < 0) {