starting tile-maze
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Sun, 25 Mar 2018 22:08:06 +0000 (01:08 +0300)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Sun, 25 Mar 2018 22:08:06 +0000 (01:08 +0300)
src/tilemaze.c [new file with mode: 0644]
src/tilemaze.h [new file with mode: 0644]

diff --git a/src/tilemaze.c b/src/tilemaze.c
new file mode 100644 (file)
index 0000000..1d413d9
--- /dev/null
@@ -0,0 +1,62 @@
+#include <stdlib.h>
+#include "tilemaze.h"
+#include "mesh.h"
+
+struct object {
+       char *name;
+       struct g3d_mesh mesh;
+
+       void *texels;
+       int tex_width, tex_height;
+
+       struct object *next;
+};
+
+struct tile {
+       struct object *objlist;
+};
+
+struct tilemaze {
+       struct tile *tileset;
+       int num_tiles;
+
+       struct object *objects;
+};
+
+
+struct tilemaze *load_tilemaze(const char *fname)
+{
+       struct tilemaze *tmz;
+
+       if(!(tmz = calloc(sizeof *tmz, 1))) {
+               return 0;
+       }
+       /* TODO */
+       return tmz;
+}
+
+void destroy_tilemaze(struct tilemaze *tmz)
+{
+       if(!tmz) return;
+
+       free(tmz->tileset);
+
+       while(tmz->objects) {
+               struct object *o = tmz->objects;
+               tmz->objects = tmz->objects->next;
+
+               free(o->mesh.varr);
+               free(o->mesh.iarr);
+               free(o);
+       }
+
+       free(tmz);
+}
+
+void update_tilemaze(struct tilemaze *tmz)
+{
+}
+
+void draw_tilemaze(struct tilemaze *tmz)
+{
+}
diff --git a/src/tilemaze.h b/src/tilemaze.h
new file mode 100644 (file)
index 0000000..a06acd8
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef TILEMAZE_H_
+#define TILEMAZE_H_
+
+struct tilemaze;
+
+struct tilemaze *load_tilemaze(const char *fname);
+void destroy_tilemaze(struct tilemaze *tmz);
+
+void update_tilemaze(struct tilemaze *tmz);
+void draw_tilemaze(struct tilemaze *tmz);
+
+#endif /* TILEMAZE_H_ */