diff options
Diffstat (limited to 'src/ft_tex_init.c')
-rw-r--r-- | src/ft_tex_init.c | 64 |
1 files changed, 53 insertions, 11 deletions
diff --git a/src/ft_tex_init.c b/src/ft_tex_init.c index 40e39e5..adc7fd0 100644 --- a/src/ft_tex_init.c +++ b/src/ft_tex_init.c @@ -21,28 +21,70 @@ ** 2 : ea ** 3 : we ** 4 : sprite +** 5 : new level door */ -void ft_wall_tex_init(t_cub *cl) +static void + ft_get_nlvl_img(t_cub *cl) { - cl->tlist[0].img = mlx_xpm_file_to_image(cl->wlist->wlx, - cl->mlist->no_tex_path, &cl->tlist[0].img_w, &cl->tlist[0].img_h); + 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, + 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); +} + +static void + ft_wall_tex_init_norme(t_cub *cl) +{ + if (cl->mlist.isnlvl) + ft_get_nlvl_img(cl); + if (cl->mlist.isftex) + ft_get_floor_tex(cl); + if (cl->mlist.isctex) + ft_get_ceil_tex(cl); + cl->walltexgood = 1; +} + +void + ft_wall_tex_init(t_cub *cl) +{ + cl->tlist[0].img = mlx_xpm_file_to_image(cl->wlist.wlx, + cl->mlist.no_tex_path, &cl->tlist[0].img_w, &cl->tlist[0].img_h); cl->tlist[0].ptr = mlx_get_data_addr(cl->tlist[0].img, &cl->tlist[0].bpp, &cl->tlist[0].sizeline, &cl->tlist[0].endian); - cl->tlist[1].img = mlx_xpm_file_to_image(cl->wlist->wlx, - cl->mlist->so_tex_path, &cl->tlist[1].img_w, &cl->tlist[1].img_h); + cl->tlist[1].img = mlx_xpm_file_to_image(cl->wlist.wlx, + cl->mlist.so_tex_path, &cl->tlist[1].img_w, &cl->tlist[1].img_h); cl->tlist[1].ptr = mlx_get_data_addr(cl->tlist[1].img, &cl->tlist[1].bpp, &cl->tlist[1].sizeline, &cl->tlist[1].endian); - cl->tlist[2].img = mlx_xpm_file_to_image(cl->wlist->wlx, - cl->mlist->ea_tex_path, &cl->tlist[2].img_w, &cl->tlist[2].img_h); + cl->tlist[2].img = mlx_xpm_file_to_image(cl->wlist.wlx, + cl->mlist.ea_tex_path, &cl->tlist[2].img_w, &cl->tlist[2].img_h); cl->tlist[2].ptr = mlx_get_data_addr(cl->tlist[2].img, &cl->tlist[2].bpp, &cl->tlist[2].sizeline, &cl->tlist[2].endian); - cl->tlist[3].img = mlx_xpm_file_to_image(cl->wlist->wlx, - cl->mlist->we_tex_path, &cl->tlist[3].img_w, &cl->tlist[3].img_h); + cl->tlist[3].img = mlx_xpm_file_to_image(cl->wlist.wlx, + cl->mlist.we_tex_path, &cl->tlist[3].img_w, &cl->tlist[3].img_h); cl->tlist[3].ptr = mlx_get_data_addr(cl->tlist[3].img, &cl->tlist[3].bpp, &cl->tlist[3].sizeline, &cl->tlist[3].endian); - cl->tlist[4].img = mlx_xpm_file_to_image(cl->wlist->wlx, - cl->mlist->sprite_path, &cl->tlist[4].img_w, &cl->tlist[4].img_h); + cl->tlist[4].img = mlx_xpm_file_to_image(cl->wlist.wlx, + cl->mlist.sprite_path, &cl->tlist[4].img_w, &cl->tlist[4].img_h); cl->tlist[4].ptr = mlx_get_data_addr(cl->tlist[4].img, &cl->tlist[4].bpp, &cl->tlist[4].sizeline, &cl->tlist[4].endian); + ft_wall_tex_init_norme(cl); } |