summaryrefslogtreecommitdiff
path: root/src/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.c')
-rw-r--r--src/map.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/map.c b/src/map.c
new file mode 100644
index 0000000..e3fc6d2
--- /dev/null
+++ b/src/map.c
@@ -0,0 +1,54 @@
+#include "map.h"
+#include "cfg.h"
+#include "../map/maps.h"
+#include <stddef.h>
+
+static unsigned int map_id = 0;
+
+void
+map_next(void)
+{
+ if (tmj2c_maps[map_id + 1] != NULL)
+ map_id += 1;
+}
+
+int
+map_width(void)
+{
+ return tmj2c_maps[map_id]->width;
+}
+
+int
+map_height(void)
+{
+ return tmj2c_maps[map_id]->height;
+}
+
+int
+map_get(int x, int y)
+{
+ if (x < 0 || y < 0 || x >= map_width() || y >= map_height())
+ return 1;
+ return tmj2c_maps[map_id]->layers[0].data[x + y * map_width()];
+}
+
+int
+map_get_px(int x, int y)
+{
+ if (x < 0 || y < 0)
+ return 1;
+ return map_get(x / TSIZE, y / TSIZE);
+}
+
+void
+map_draw(void)
+{
+}
+
+const Tmj2cObject *
+map_objects(unsigned int *size)
+{
+ if (size != NULL)
+ *size = tmj2c_maps[map_id]->numobjects;
+ return tmj2c_maps[map_id]->objects;
+}