diff options
author | P. J. McDermott <pj@pehjota.net> | 2021-03-30 02:34:03 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2021-03-30 02:35:54 (EDT) |
commit | 238a78197b13c0784c922cd665af8c3912600a86 (patch) | |
tree | a15debe26f10beae3411b4749941fe2a4cd00296 | |
parent | db9eca5b58ad505d306fb3b70a70ba1232ddc265 (diff) | |
download | dodge-balls-238a78197b13c0784c922cd665af8c3912600a86.zip dodge-balls-238a78197b13c0784c922cd665af8c3912600a86.tar.gz dodge-balls-238a78197b13c0784c922cd665af8c3912600a86.tar.bz2 |
map: Add line accessor functions
-rw-r--r-- | src/map.c | 29 | ||||
-rw-r--r-- | src/map.h | 7 |
2 files changed, 36 insertions, 0 deletions
@@ -1148,3 +1148,32 @@ db_map_tile_ball_collides(struct db_map *map, int x, int y) i = y * map->w + x; return (map->b_col[i / 8] & (1 << (i % 8))) != 0; } + +struct db_map_line * +db_map_get_lines(struct db_map *map) +{ + return map->line_head; +} + +int +db_map_line_get_coords(struct db_map_line *line, + int *x1, int *y1, int *x2, int *y2) +{ + if (line == NULL) { + return -1; + } + *x1 = line->x1; + *y1 = line->y1; + *x2 = line->x2; + *y2 = line->y2; + return 1; +} + +struct db_map_line * +db_map_line_get_next(struct db_map_line *line) +{ + if (line == NULL) { + return NULL; + } + return line->next; +} @@ -24,6 +24,7 @@ #include "tileset.h" struct db_map; +struct db_map_line; struct db_map *db_map_new(const char *game_id, const char *level_id); SDL_Texture *db_map_render(struct db_map *map, SDL_Renderer *renderer); @@ -40,5 +41,11 @@ 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__)); +struct db_map_line *db_map_get_lines(struct db_map *map) + __attribute__((__pure__)); +int db_map_line_get_coords(struct db_map_line *line, + int *x1, int *y1, int *x2, int *y2); +struct db_map_line *db_map_line_get_next(struct db_map_line *line) + __attribute__((__pure__)); #endif /* DB_MAP_H_ */ |