From 79af897f235b2172ce37e6d30b829fa0928aef3a Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 11 Mar 2020 09:17:49 +0100 Subject: Good trap init --- src/ft_tex_init.c | 89 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 40 deletions(-) (limited to 'src/ft_tex_init.c') 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 /* -** 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 -- cgit v1.2.3 From c581c7e3543058f015bddf96d76ac2d771ea40a0 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 11 Mar 2020 10:16:48 +0100 Subject: Nice parse --- src/ft_tex_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ft_tex_init.c') diff --git a/src/ft_tex_init.c b/src/ft_tex_init.c index 32bfb66..30b738e 100644 --- a/src/ft_tex_init.c +++ b/src/ft_tex_init.c @@ -71,7 +71,7 @@ static void cl->tlist[6].ptr = mlx_get_data_addr(cl->tlist[6].img, &cl->tlist[6].bpp, &cl->tlist[6].sizeline, &cl->tlist[6].endian); } - if (cl->mlist.istrap) + if (cl->mlist.istraps) { 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); -- cgit v1.2.3