aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/cub3d_structs.h2
-rw-r--r--map/lvl_one.cub18
-rw-r--r--map/lvl_two.cub26
-rw-r--r--src/ft_exit.c1
-rw-r--r--src/ft_init_map.c23
5 files changed, 64 insertions, 6 deletions
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index a173e8c..ebea0f7 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -110,6 +110,7 @@ typedef struct s_map
char *ea_tex_path;
char *we_tex_path;
char *sprite_path;
+ char *nlevel_path;
char *mapl;
char **map;
int8_t x_step;
@@ -119,6 +120,7 @@ typedef struct s_map
size_t line_chk;
size_t map_start;
uint8_t isspawn;
+ uint8_t isnlvl;
uint8_t scale;
} t_map;
diff --git a/map/lvl_one.cub b/map/lvl_one.cub
new file mode 100644
index 0000000..627a774
--- /dev/null
+++ b/map/lvl_one.cub
@@ -0,0 +1,18 @@
+R 1000 720
+
+NO ./media/img/BRIQUASSES.xpm
+SO ./media/img/BRIQUASSES.xpm
+EA ./media/img/hey.xpm
+WE ./media/img/left_arrow.xpm
+S ./media/img/segfot.xpm
+
+C 50,100,200
+F 50,190,124
+
+L ./map/lvl_two.cub
+
+1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 L 0 0 1
+1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1
+1 E 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
+1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \ No newline at end of file
diff --git a/map/lvl_two.cub b/map/lvl_two.cub
new file mode 100644
index 0000000..301782c
--- /dev/null
+++ b/map/lvl_two.cub
@@ -0,0 +1,26 @@
+R 1400 900
+
+NO ./media/img/BRIQUASSES.xpm
+SO ./media/img/BRIQUASSE_3.xpm
+EA ./media/img/BRIQUASSES_2.xpm
+WE ./media/img/MURLOL.xpm
+S ./media/img/pillar.xpm
+
+C 50,100,200
+F 50,190,124
+
+1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1
+1 0 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0 1
+1 N 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1
+1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1
+1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1
+1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
+1 0 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1
+1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1
+1 1 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1
+1 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 1 1
+1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1
+1 1 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1
+1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 1 1
+1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \ No newline at end of file
diff --git a/src/ft_exit.c b/src/ft_exit.c
index b9e061f..97671d6 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -25,6 +25,7 @@ static void
ft_memdel((void**)&clist->mlist->ea_tex_path);
ft_memdel((void**)&clist->mlist->we_tex_path);
ft_memdel((void**)&clist->mlist->sprite_path);
+ ft_memdel((void**)&clist->mlist->nlevel_path);
ft_memdel((void**)&clist->mlist->mapl);
ft_free_words(clist->mlist->map);
ft_memdel((void**)&clist->mlist);
diff --git a/src/ft_init_map.c b/src/ft_init_map.c
index cc767f6..0eb2ab2 100644
--- a/src/ft_init_map.c
+++ b/src/ft_init_map.c
@@ -13,22 +13,32 @@
#include <libft.h>
#include <cub3d.h>
#include <stdlib.h>
+#include <stdint.h>
-t_map
- *ft_init_map(void)
+static int8_t
+ ft_init_map_callocs(t_map *mlist)
{
- t_map *mlist;
-
- if (!(mlist = (t_map*)malloc(sizeof(t_map))))
- return (NULL);
if (!(mlist->no_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->so_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->ea_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->we_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->sprite_path = (char*)ft_calloc(1, sizeof(char))) ||
+ !(mlist->nlevel_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->mapl = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->map = (char**)ft_calloc(2, sizeof(char*))) ||
!(mlist->map[0] = (char*)ft_calloc(1, sizeof(char))))
+ return (-1);
+ return (0);
+}
+
+t_map
+ *ft_init_map(void)
+{
+ t_map *mlist;
+
+ if (!(mlist = (t_map*)malloc(sizeof(t_map))))
+ return (NULL);
+ if (ft_init_map_callocs(mlist) < 0)
return (NULL);
mlist->map[1] = 0;
mlist->map_w = 0;
@@ -38,6 +48,7 @@ t_map
mlist->line_chk = 0;
mlist->map_start = 0;
mlist->isspawn = 0;
+ mlist->isnlvl = 0;
mlist->scale = 0;
return (mlist);
}