replace context offset with Camera2D

This commit is contained in:
Luka Jankovic 2025-08-13 23:48:14 +02:00
parent 2026f8ac8d
commit af7d6dee00
11 changed files with 132 additions and 70 deletions

View file

@ -40,8 +40,7 @@ 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, int offset_x,
int offset_y) {
void kubo_wall_render(struct kubo_wall *wall, bool select, Camera2D *camera) {
Color wall_color =
(select && wall->state == KUBO_WALL_SELECTED) ? BLUE : BLACK;
@ -50,15 +49,12 @@ void kubo_wall_render(struct kubo_wall *wall, bool select, int offset_x,
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 mouse = GetScreenToWorld2D(GetMousePosition(), *camera);
Vector2 mouse_points[] = {points[wall->vertices.count - 1], mouse};
DrawSplineLinear(mouse_points, 2, 10.f, wall_color);