Add generic dynamic array type

This commit is contained in:
Luka Jankovic 2025-06-17 01:05:40 +02:00
parent 89e548eca8
commit 7769f5fd58
6 changed files with 94 additions and 79 deletions

View file

@ -4,6 +4,8 @@
#include <stdlib.h>
#include <raylib.h>
#include "kubo_dynarray.h"
#define KUBO_WALL_INIT_VERTICES 4
enum kubo_wall_state {
@ -12,17 +14,18 @@ enum kubo_wall_state {
KUBO_WALL_DONE
};
struct kubo_wall {
Vector2 *vertices;
unsigned int num_vertices;
unsigned int num_vertices_alloc;
KUBO_DYNARRAY_REGISTER(kubo_vector2_arr, Vector2)
struct kubo_wall {
struct kubo_vector2_arr vertices;
enum kubo_wall_state state;
};
struct kubo_wall *kubo_wall_init();
void kubo_wall_cleanup(struct kubo_wall *wall);
bool kubo_wall_append(struct kubo_wall *wall, Vector2 vertex);
bool kubo_wall_add_vertex(struct kubo_wall *wall, Vector2 vec);
Vector2 kubo_wall_get_vertex(struct kubo_wall *wall, size_t index);
#endif