diff options
-rw-r--r-- | inc/cub3d_structs.h | 7 | ||||
-rw-r--r-- | src/ft_exit.c | 1 | ||||
-rw-r--r-- | src/ft_init_map.c | 2 | ||||
-rw-r--r-- | src/ft_tex_init.c | 89 | ||||
-rw-r--r-- | src/ft_warp_level.c | 1 |
5 files changed, 59 insertions, 41 deletions
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index 144de6f..9f48975 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -169,6 +169,7 @@ typedef struct s_map char *ce_tex_path; char *nlevel_path; char *skybox_path; + char *traps_path; char *music_path; char *music_cmd; char *mapl; @@ -181,6 +182,8 @@ typedef struct s_map size_t mapl_len; int32_t sprite_nbr; int32_t sprite_order[12]; + int32_t traps_nbr; + int32_t traps_order[12]; size_t line_chk; size_t map_start; uint8_t isspawn; @@ -189,6 +192,7 @@ typedef struct s_map uint8_t isftex; uint8_t isctex; uint8_t isskybox; + uint8_t istrap; uint8_t darklvl; uint8_t scale; uint32_t nlx; @@ -219,8 +223,9 @@ typedef struct s_cub struct s_img img; struct s_rgb f_rgb; struct s_rgb c_rgb; - struct s_img tlist[8]; + struct s_img tlist[16]; struct s_sprite sprites[4096]; + struct s_sprite traps[4096]; } t_cub; # endif diff --git a/src/ft_exit.c b/src/ft_exit.c index fb6de09..3b00701 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -33,6 +33,7 @@ static void ft_memdel((void**)&clist->mlist.ce_tex_path); ft_memdel((void**)&clist->mlist.nlevel_path); ft_memdel((void**)&clist->mlist.skybox_path); + ft_memdel((void**)&clist->mlist.traps_path); ft_memdel((void**)&clist->mlist.music_path); ft_memdel((void**)&clist->mlist.music_cmd); ft_memdel((void**)&clist->mlist.mapl); diff --git a/src/ft_init_map.c b/src/ft_init_map.c index 27b4a39..f2b0726 100644 --- a/src/ft_init_map.c +++ b/src/ft_init_map.c @@ -29,6 +29,7 @@ static int8_t !(mlist->ce_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->nlevel_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->skybox_path = (char*)ft_calloc(1, sizeof(char))) || + !(mlist->traps_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->music_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->music_cmd = (char*)ft_calloc(1, sizeof(char))) || !(mlist->mapl = (char*)ft_calloc(1, sizeof(char))) || @@ -60,6 +61,7 @@ int8_t mlist->isnlvl = 0; mlist->ismusic = 0; mlist->isskybox = 0; + mlist->istrap = 0; mlist->darklvl = 0; mlist->scale = 0; mlist->nlx = 0; diff --git a/src/ft_tex_init.c b/src/ft_tex_init.c index 4cbdf73..32bfb66 100644 --- a/src/ft_tex_init.c +++ b/src/ft_tex_init.c @@ -16,60 +16,69 @@ #include <mlx.h> /* -** 0 : no -** 1 : so -** 2 : ea -** 3 : we -** 4 : sprite -** 5 : new level door -** 6 : floor -** 7 : ceil +** 0 : no +** 1 : so +** 2 : ea +** 3 : we +** 4 : sprite 1 +** 5 : new level door +** 6 : floor +** 7 : ceil / skybox +** 8 : sprite 2 +** 9 : sprite 3 +** 10 : sprite 4 +** 11 : sprite 5 +** 12 : sprite 6 +** 13 : sprite 7 +** 14 : sprite 8 +** 15 : trap */ static void - ft_get_nlvl_img(t_cub *cl) + ft_wall_tex_init_norme_bis(t_cub *cl) { - cl->tlist[5].img = mlx_xpm_file_to_image(cl->wlist.wlx, - cl->mlist.nl_tex_path, &cl->tlist[5].img_w, &cl->tlist[5].img_h); - cl->tlist[5].ptr = mlx_get_data_addr(cl->tlist[5].img, - &cl->tlist[5].bpp, &cl->tlist[5].sizeline, &cl->tlist[5].endian); -} - -static void - ft_get_floor_tex(t_cub *cl) -{ - cl->tlist[6].img = mlx_xpm_file_to_image(cl->wlist.wlx, - cl->mlist.fl_tex_path, &cl->tlist[6].img_w, &cl->tlist[6].img_h); - cl->tlist[6].ptr = mlx_get_data_addr(cl->tlist[6].img, - &cl->tlist[6].bpp, &cl->tlist[6].sizeline, &cl->tlist[6].endian); -} - -static void - ft_get_ceil_tex(t_cub *cl) -{ - cl->tlist[7].img = mlx_xpm_file_to_image(cl->wlist.wlx, + if (cl->mlist.isctex) + { + cl->tlist[7].img = mlx_xpm_file_to_image(cl->wlist.wlx, cl->mlist.ce_tex_path, &cl->tlist[7].img_w, &cl->tlist[7].img_h); - cl->tlist[7].ptr = mlx_get_data_addr(cl->tlist[7].img, - &cl->tlist[7].bpp, &cl->tlist[7].sizeline, &cl->tlist[7].endian); + cl->tlist[7].ptr = mlx_get_data_addr(cl->tlist[7].img, + &cl->tlist[7].bpp, &cl->tlist[7].sizeline, &cl->tlist[7].endian); + } + if (cl->mlist.isskybox) + { + cl->tlist[7].img = mlx_xpm_file_to_image(cl->wlist.wlx, + cl->mlist.skybox_path, &cl->tlist[7].img_w, &cl->tlist[7].img_h); + cl->tlist[7].ptr = mlx_get_data_addr(cl->tlist[7].img, + &cl->tlist[7].bpp, &cl->tlist[7].sizeline, &cl->tlist[7].endian); + } + cl->walltexgood = 1; } static void ft_wall_tex_init_norme(t_cub *cl) { if (cl->mlist.isnlvl) - ft_get_nlvl_img(cl); + { + cl->tlist[5].img = mlx_xpm_file_to_image(cl->wlist.wlx, + cl->mlist.nl_tex_path, &cl->tlist[5].img_w, &cl->tlist[5].img_h); + cl->tlist[5].ptr = mlx_get_data_addr(cl->tlist[5].img, + &cl->tlist[5].bpp, &cl->tlist[5].sizeline, &cl->tlist[5].endian); + } if (cl->mlist.isftex) - ft_get_floor_tex(cl); - if (cl->mlist.isctex) - ft_get_ceil_tex(cl); - if (cl->mlist.isskybox) { - cl->tlist[7].img = mlx_xpm_file_to_image(cl->wlist.wlx, - cl->mlist.skybox_path, &cl->tlist[7].img_w, &cl->tlist[7].img_h); - cl->tlist[7].ptr = mlx_get_data_addr(cl->tlist[7].img, - &cl->tlist[7].bpp, &cl->tlist[7].sizeline, &cl->tlist[7].endian); + cl->tlist[6].img = mlx_xpm_file_to_image(cl->wlist.wlx, + cl->mlist.fl_tex_path, &cl->tlist[6].img_w, &cl->tlist[6].img_h); + cl->tlist[6].ptr = mlx_get_data_addr(cl->tlist[6].img, + &cl->tlist[6].bpp, &cl->tlist[6].sizeline, &cl->tlist[6].endian); } - cl->walltexgood = 1; + if (cl->mlist.istrap) + { + cl->tlist[15].img = mlx_xpm_file_to_image(cl->wlist.wlx, + cl->mlist.traps_path, &cl->tlist[15].img_w, &cl->tlist[15].img_h); + cl->tlist[15].ptr = mlx_get_data_addr(cl->tlist[15].img, + &cl->tlist[15].bpp, &cl->tlist[15].sizeline, &cl->tlist[15].endian); + } + ft_wall_tex_init_norme_bis(cl); } void diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c index 1f744c2..3c9110f 100644 --- a/src/ft_warp_level.c +++ b/src/ft_warp_level.c @@ -34,6 +34,7 @@ static void ft_memdel((void**)&ml->ce_tex_path); ft_memdel((void**)&ml->nlevel_path); ft_memdel((void**)&ml->skybox_path); + ft_memdel((void**)&ml->traps_path); ft_memdel((void**)&ml->music_path); ft_memdel((void**)&ml->music_cmd); ft_memdel((void**)&ml->mapl); |