diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-11 09:17:49 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-11 09:17:49 +0100 |
commit | 79af897f235b2172ce37e6d30b829fa0928aef3a (patch) | |
tree | d585fe7f2ab852c7ebc781e553669a6cff34034d /src | |
parent | ft_calc_sprite in a better location, still sliding like a champ (diff) | |
download | 42-cub3d-79af897f235b2172ce37e6d30b829fa0928aef3a.tar.gz 42-cub3d-79af897f235b2172ce37e6d30b829fa0928aef3a.tar.bz2 42-cub3d-79af897f235b2172ce37e6d30b829fa0928aef3a.tar.xz 42-cub3d-79af897f235b2172ce37e6d30b829fa0928aef3a.tar.zst 42-cub3d-79af897f235b2172ce37e6d30b829fa0928aef3a.zip |
Good trap init
Diffstat (limited to '')
-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 |
4 files changed, 53 insertions, 40 deletions
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); |