diff options
Diffstat (limited to 'map.h')
-rw-r--r-- | map.h | 64 |
1 files changed, 64 insertions, 0 deletions
@@ -0,0 +1,64 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* map.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kdx <kdx @student.42angouleme.fr +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/10/10 07:29:31 by kdx #+# #+# */ +/* Updated: 2022/10/16 00:12:59 by kdx ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef MAP_H +# define MAP_H +# include "libft/libft.h" +# include "sily.h" +# define TSIZE 16 + +enum +{ + TILE_NONE = '0', + TILE_WALL = '1', + TILE_COLLECTIBLE = 'C', + TILE_EXIT = 'E', + TILE_PLAYER = 'P', +}; + +enum +{ + ERR_NONE, + ERR_OPEN, + ERR_READ, + ERR_MALLOC, + ERR_INVALID_CHAR, + ERR_WRONG_DIMENSION, + ERR_FILENAME, + ERR_MISSING, + ERR_DUPLICATE, + ERR_OPEN_BORDER, + ERR_NO_PATH, +}; + +typedef struct s_map +{ + unsigned char *data; + size_t width; + size_t height; + size_t exit[2]; +} t_map; + +t_err map_load(t_map *map, const char *path); +void map_destroy(t_map *map); +const char *map_load_error(t_err err); +void map_draw_tile(t_sily *sily, t_map *map, int x, int y); +void map_draw(t_sily *sily, t_map *map); +void map_spawn(t_game *game, t_map *map); +unsigned char map_get(t_map *map, int x, int y); +void map_set(t_map *map, int x, int y, unsigned char v); +size_t map_count(t_map *map, int v); + +t_err map_verify(t_map *map, const unsigned char *data); +t_err map_pathfind(t_map *map); + +#endif |