loading scene from file
This commit is contained in:
parent
8554b33cd6
commit
024349a59f
7 changed files with 44 additions and 29 deletions
22
kubo_file.c
22
kubo_file.c
|
|
@ -1,6 +1,6 @@
|
|||
#include "kubo_file.h"
|
||||
|
||||
void kubo_file_parse(char *file_name) {
|
||||
struct kubo_context kubo_file_parse(char *file_name) {
|
||||
static const cyaml_config_t config = {
|
||||
.log_fn = cyaml_log,
|
||||
.mem_fn = cyaml_mem,
|
||||
|
|
@ -15,16 +15,30 @@ void kubo_file_parse(char *file_name) {
|
|||
printf("cyaml err\n");
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < n->walls_count; i++) {
|
||||
struct kubo_context context;
|
||||
kubo_context_init(&context);
|
||||
|
||||
for (size_t i = 0; i < n->walls_count; i++) {
|
||||
printf("wall:\n");
|
||||
for (unsigned j = 0; j < n->walls[i].vertices_count; j++) {
|
||||
printf("\t%f:%f\n", n->walls[i].vertices[j][0],
|
||||
struct kubo_wall *wall = malloc(sizeof(struct kubo_wall));
|
||||
kubo_wall_init(wall);
|
||||
for (size_t j = 0; j < n->walls[i].vertices_count; j++) {
|
||||
printf("\t%i:%i\n", n->walls[i].vertices[j][0],
|
||||
n->walls[i].vertices[j][1]);
|
||||
Vector2 vertex = {
|
||||
.x = n->walls[i].vertices[j][0],
|
||||
.y = n->walls[i].vertices[j][1]
|
||||
};
|
||||
kubo_wall_add_vertex(wall, vertex);
|
||||
}
|
||||
|
||||
kubo_wall_arr_add(&context.walls, wall);
|
||||
}
|
||||
|
||||
err = cyaml_free(&config, &top_schema, n, 0);
|
||||
if (err != CYAML_OK) {
|
||||
printf("cyaml free err\n");
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue