Moved wall render function

This commit is contained in:
Luka Jankovic 2025-06-21 17:42:29 +02:00
parent aeeaab0ad7
commit b0087c772a
3 changed files with 15 additions and 10 deletions

View file

@ -43,3 +43,14 @@ bool kubo_wall_add_vertex(struct kubo_wall *wall, Vector2 vec) {
Vector2 kubo_wall_get_vertex(struct kubo_wall *wall, size_t index) {
return kubo_vector2_arr_get(&wall->vertices, index);
}
void kubo_wall_render(struct kubo_wall *wall) {
DrawSplineLinear(wall->vertices.data, wall->vertices.count, 10.f, BLACK);
if (wall->state == KUBO_WALL_DRAWING) {
Vector2 mouse = GetMousePosition();
Vector2 points[] = {wall->vertices.data[wall->vertices.count - 1],
mouse};
DrawSplineLinear(points, 2, 10.f, BLACK);
}
}

View file

@ -45,5 +45,7 @@ void kubo_wall_cleanup(struct kubo_wall *wall);
bool kubo_wall_add_vertex(struct kubo_wall *wall, Vector2 vec);
Vector2 kubo_wall_get_vertex(struct kubo_wall *wall, size_t index);
void kubo_wall_render(struct kubo_wall *wall);
#endif

View file

@ -41,16 +41,8 @@ void kubo_window_render(struct kubo_context *context) {
for (int i = 0; i < context->walls.count; i++) {
struct kubo_wall *wall = kubo_wall_arr_get(&context->walls, i);
assert(wall != NULL);
DrawSplineLinear(wall->vertices.data, wall->vertices.count, 10.f,
BLACK);
if (wall->state == KUBO_WALL_DRAWING) {
Vector2 mouse = GetMousePosition();
Vector2 points[] = {wall->vertices.data[wall->vertices.count - 1],
mouse};
DrawSplineLinear(points, 2, 10.f, BLACK);
}
kubo_wall_render(wall);
}
EndDrawing();