Add generic dynamic array type
This commit is contained in:
parent
89e548eca8
commit
7769f5fd58
6 changed files with 94 additions and 79 deletions
|
|
@ -34,15 +34,17 @@ void kubo_window_render(struct kubo_context *context) {
|
|||
DrawSplineLinear(points, 2, 10.f, BLACK);
|
||||
}
|
||||
|
||||
for (int i = 0; i < context->num_walls; i++) {
|
||||
DrawSplineLinear(context->walls[i]->vertices,
|
||||
context->walls[i]->num_vertices, 10.f, BLACK);
|
||||
if (context->walls[i]->state == KUBO_WALL_STARTED) {
|
||||
Vector2 mouse_pos = GetMousePosition();
|
||||
Vector2 points[] = {
|
||||
context->walls[i]
|
||||
->vertices[context->walls[i]->num_vertices - 1],
|
||||
mouse_pos};
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -59,8 +61,8 @@ void kubo_window_input(struct kubo_context *context) {
|
|||
|
||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
|
||||
Vector2 new_pos = GetMousePosition();
|
||||
kubo_wall_append(current_wall, new_pos);
|
||||
current_wall->state = KUBO_WALL_STARTED;
|
||||
kubo_wall_add_vertex(current_wall, new_pos);
|
||||
current_wall->state = KUBO_WALL_DRAWING;
|
||||
} else if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) {
|
||||
current_wall->state = KUBO_WALL_DONE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue