summaryrefslogtreecommitdiff
path: root/map.h
diff options
context:
space:
mode:
Diffstat (limited to 'map.h')
-rw-r--r--map.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/map.h b/map.h
new file mode 100644
index 0000000..b4ce641
--- /dev/null
+++ b/map.h
@@ -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