aboutsummaryrefslogtreecommitdiff
path: root/src/map.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-06-15 21:41:09 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-06-15 21:41:09 +0100
commit18080fdf599adbf13a643fc450cd3fe42c871cb0 (patch)
treeaac778a674c52ec2ccae7c43af64424e76cd0970 /src/map.c
parent8d1cfe3e409afd388ff68fc776677fc961e5446c (diff)
downloadgold-mine-run-18080fdf599adbf13a643fc450cd3fe42c871cb0.tar.gz
gold-mine-run-18080fdf599adbf13a643fc450cd3fe42c871cb0.zip
Add map collision detection functions
Diffstat (limited to 'src/map.c')
-rw-r--r--src/map.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/map.c b/src/map.c
index 55fc470..87a0b3b 100644
--- a/src/map.c
+++ b/src/map.c
@@ -5,6 +5,7 @@
#include "map.h"
+/* current map; set via map_init */
static const uint8_t *cmap;
void map_init(const uint8_t map[])
@@ -14,7 +15,6 @@ void map_init(const uint8_t map[])
void map_render()
{
- const uint8_t *tiles = binary_tiles_start;
Rect src = { 0, 0, 160, 48 };
Rect dst = { 0, 0, 8, 8 };
@@ -31,3 +31,13 @@ void map_render()
blitrc(binary_tiles_start, &src, &dst);
}
}
+
+uint8_t map_is_blocked(uint16_t x, uint16_t y)
+{
+ return cmap[(x / MAP_TILE_W) + (y / MAP_TILE_H) * MAP_W] >= MAP_FIRST_BLOCKED;
+}
+
+uint8_t map_is_deadly(uint16_t x, uint16_t y)
+{
+ return cmap[(x / MAP_TILE_W) + (y / MAP_TILE_H) * MAP_W] >= MAP_FIRST_DEADLY;
+}