2 #include "system/stacktrace.h"
8 #include "system/log.h"
10 #include "system/nth_alloc.h"
11 #include "wavy_rect.h"
13 #define WAVE_PILLAR_WIDTH 10.0f
24 Wavy_rect *create_wavy_rect(Rect rect, Color color)
28 Wavy_rect *wavy_rect = PUSH_LT(lt, nth_calloc(1, sizeof(Wavy_rect)), free);
29 if (wavy_rect == NULL) {
33 wavy_rect->rect = rect;
34 wavy_rect->color = color;
35 wavy_rect->angle = 0.0f;
41 void destroy_wavy_rect(Wavy_rect *wavy_rect)
43 trace_assert(wavy_rect);
44 RETURN_LT0(wavy_rect->lt);
47 int wavy_rect_render(const Wavy_rect *wavy_rect,
50 trace_assert(wavy_rect);
54 for (float wave_scanner = 0;
55 wave_scanner < wavy_rect->rect.w;
56 wave_scanner += WAVE_PILLAR_WIDTH) {
58 const float s = (float) (rand() % 50) * 0.1f;
62 wavy_rect->rect.x + wave_scanner,
63 wavy_rect->rect.y + s * sinf(wavy_rect->angle + wave_scanner / WAVE_PILLAR_WIDTH),
64 WAVE_PILLAR_WIDTH * 1.20f,
66 wavy_rect->color) < 0) {
70 srand((unsigned int) time(NULL));
75 int wavy_rect_update(Wavy_rect *wavy_rect,
78 trace_assert(wavy_rect);
79 wavy_rect->angle = fmodf(wavy_rect->angle + 2.0f * delta_time, 2 * PI);
84 Rect wavy_rect_hitbox(const Wavy_rect *wavy_rect)
86 return wavy_rect->rect;