kubo/kubo_wall.c

45 lines
1.3 KiB
C

/*
* Copyright Luka Jankovic 2025
*
* This file is part of Kubo.
*
* Kubo is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* Kubo is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Kubo. If not, see <https://www.gnu.org/licenses/>.
*/
#include "kubo_wall.h"
struct kubo_wall *kubo_wall_init() {
struct kubo_wall *wall = malloc(sizeof(struct kubo_wall));
if (!wall)
return NULL;
wall->state = KUBO_WALL_INIT;
kubo_vector2_arr_init(&wall->vertices);
return wall;
}
void kubo_wall_cleanup(struct kubo_wall *wall) {
kubo_vector2_arr_free(&wall->vertices);
free(wall);
}
bool kubo_wall_add_vertex(struct kubo_wall *wall, Vector2 vec) {
return kubo_vector2_arr_add(&wall->vertices, vec);
}
Vector2 kubo_wall_get_vertex(struct kubo_wall *wall, size_t index) {
return kubo_vector2_arr_get(&wall->vertices, index);
}