2 #include "system/stacktrace.h"
8 #include "system/line_stream.h"
9 #include "system/log.h"
10 #include "system/lt.h"
11 #include "system/nth_alloc.h"
12 #include "wavy_rect.h"
14 #define WAVE_PILLAR_WIDTH 10.0f
25 Wavy_rect *create_wavy_rect(Rect rect, Color color)
29 Wavy_rect *wavy_rect = PUSH_LT(lt, nth_calloc(1, sizeof(Wavy_rect)), free);
30 if (wavy_rect == NULL) {
34 wavy_rect->rect = rect;
35 wavy_rect->color = color;
36 wavy_rect->angle = 0.0f;
42 void destroy_wavy_rect(Wavy_rect *wavy_rect)
44 trace_assert(wavy_rect);
45 RETURN_LT0(wavy_rect->lt);
48 int wavy_rect_render(const Wavy_rect *wavy_rect,
51 trace_assert(wavy_rect);
55 for (float wave_scanner = 0;
56 wave_scanner < wavy_rect->rect.w;
57 wave_scanner += WAVE_PILLAR_WIDTH) {
59 const float s = (float) (rand() % 50) * 0.1f;
63 wavy_rect->rect.x + wave_scanner,
64 wavy_rect->rect.y + s * sinf(wavy_rect->angle + wave_scanner / WAVE_PILLAR_WIDTH),
65 WAVE_PILLAR_WIDTH * 1.20f,
67 wavy_rect->color) < 0) {
71 srand((unsigned int) time(NULL));
76 int wavy_rect_update(Wavy_rect *wavy_rect,
79 trace_assert(wavy_rect);
80 wavy_rect->angle = fmodf(wavy_rect->angle + 2.0f * delta_time, 2 * PI);
85 Rect wavy_rect_hitbox(const Wavy_rect *wavy_rect)
87 return wavy_rect->rect;