summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-27 17:17:53 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-27 17:17:53 (EDT)
commitf5afccb93da63988655817cf49741f9c0955f1a5 (patch)
tree61d250853fa185f6a88de7197e9fab3050401553
parent02c198574420b8832c4bf9741f38e1928a346286 (diff)
downloaddodge-balls-f5afccb93da63988655817cf49741f9c0955f1a5.zip
dodge-balls-f5afccb93da63988655817cf49741f9c0955f1a5.tar.gz
dodge-balls-f5afccb93da63988655817cf49741f9c0955f1a5.tar.bz2
map: Add functions to query tile collisions
-rw-r--r--src/map.c18
-rw-r--r--src/map.h4
2 files changed, 22 insertions, 0 deletions
diff --git a/src/map.c b/src/map.c
index add4c3e..53dadaf 100644
--- a/src/map.c
+++ b/src/map.c
@@ -988,3 +988,21 @@ struct db_ball *db_map_get_balls(struct db_map *map)
{
return map->ball_head;
}
+
+int
+db_map_tile_player_collides(struct db_map *map, int x, int y)
+{
+ int i;
+
+ i = y * map->w + x;
+ return (map->p_col[i / 8] & (1 << (i % 8))) != 0;
+}
+
+int
+db_map_tile_ball_collides(struct db_map *map, int x, int y)
+{
+ int i;
+
+ i = y * map->w + x;
+ return (map->b_col[i / 8] & (1 << (i % 8))) != 0;
+}
diff --git a/src/map.h b/src/map.h
index bfd544d..a2cd112 100644
--- a/src/map.h
+++ b/src/map.h
@@ -34,5 +34,9 @@ void db_map_get_player(struct db_map *map, int *x, int *y, int *r, int *gid);
void db_map_get_target(struct db_map *map, int *x, int *y, int *r, int *gid);
struct db_ball *db_map_get_balls(struct db_map *map)
__attribute__((__pure__));
+int db_map_tile_player_collides(struct db_map *map, int x, int y)
+ __attribute__((__pure__));
+int db_map_tile_ball_collides(struct db_map *map, int x, int y)
+ __attribute__((__pure__));
#endif /* DB_MAP_H_ */