diff options
author | P. 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) |
commit | f5afccb93da63988655817cf49741f9c0955f1a5 (patch) | |
tree | 61d250853fa185f6a88de7197e9fab3050401553 | |
parent | 02c198574420b8832c4bf9741f38e1928a346286 (diff) | |
download | dodge-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.c | 18 | ||||
-rw-r--r-- | src/map.h | 4 |
2 files changed, 22 insertions, 0 deletions
@@ -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; +} @@ -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_ */ |