This commit is contained in:
Luka Jankovic 2025-07-26 23:03:27 +02:00
parent 162e7a7fb0
commit 7189f28c00
8 changed files with 139 additions and 33 deletions

View file

@ -40,18 +40,29 @@ 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, bool select) {
void kubo_wall_render(struct kubo_wall *wall, bool select, int offset_x,
int offset_y) {
Color wall_color =
(select && wall->state == KUBO_WALL_SELECTED) ? BLUE : BLACK;
DrawSplineLinear(wall->vertices.data, wall->vertices.count, 10.f,
wall_color);
Vector2 *points = malloc(sizeof(Vector2) * wall->vertices.count);
for (size_t i = 0; i < wall->vertices.count; i++) {
points[i] = kubo_vector2_arr_get(&wall->vertices, i);
points[i].x += offset_x;
points[i].y += offset_y;
}
DrawSplineLinear(points, wall->vertices.count, 10.f, wall_color);
if (wall->state == KUBO_WALL_DRAWING) {
Vector2 mouse = GetMousePosition();
Vector2 points[] = {wall->vertices.data[wall->vertices.count - 1],
mouse};
DrawSplineLinear(points, 2, 10.f, wall_color);
Vector2 mouse_points[] = {points[wall->vertices.count - 1], mouse};
DrawSplineLinear(mouse_points, 2, 10.f, wall_color);
}
free(points);
}