diff options
Diffstat (limited to 'src/ft_del_tex.c')
| -rw-r--r-- | src/ft_del_tex.c | 107 | 
1 files changed, 107 insertions, 0 deletions
| diff --git a/src/ft_del_tex.c b/src/ft_del_tex.c new file mode 100644 index 0000000..70f23fa --- /dev/null +++ b/src/ft_del_tex.c @@ -0,0 +1,107 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   ft_del_tex.c                                       :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:28:46 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:28:46 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#include <cub3d.h> +#include <mlx.h> +#include <stdint.h> + +static void +	ft_del_extra_sprites(t_cub *cl) +{ +	uint8_t	i; + +	i = 1; +	while ((i + 2) <= cl->mlist.topsp) +	{ +		if (cl->tlist[i + 7].img) +			mlx_destroy_image(cl->wlist.wlx, cl->tlist[i + 7].img); +		i++; +	} +} + +static void +	ft_del_tnum(t_cub *cl) +{ +	int8_t	i; + +	i = 0; +	while (i < 12) +	{ +		if (cl->tnum[i].img) +			mlx_destroy_image(cl->wlist.wlx, cl->tnum[i].img); +		i++; +	} +} + +static void +	ft_del_tweap(t_cub *cl) +{ +	int8_t	i; + +	i = 0; +	while (i < 6) +	{ +		if (cl->tweap[i].img) +			mlx_destroy_image(cl->wlist.wlx, cl->tweap[i].img); +		i++; +	} +} + +static void +	ft_del_bonus_tex(t_cub *cl) +{ +	if (cl->mlist.isnlvl && cl->tlist[5].img) +		mlx_destroy_image(cl->wlist.wlx, cl->tlist[5].img); +	if (cl->mlist.isftex && cl->tlist[6].img) +		mlx_destroy_image(cl->wlist.wlx, cl->tlist[6].img); +	if (cl->mlist.isctex && cl->tlist[7].img) +		mlx_destroy_image(cl->wlist.wlx, cl->tlist[7].img); +	if (cl->mlist.istraps && cl->tlist[15].img) +		mlx_destroy_image(cl->wlist.wlx, cl->tlist[15].img); +	if (cl->tlist[16].img) +		mlx_destroy_image(cl->wlist.wlx, cl->tlist[16].img); +	if (cl->mlist.isheals && cl->tlist[17].img) +		mlx_destroy_image(cl->wlist.wlx, cl->tlist[17].img); +	if (cl->tlist[18].img) +		mlx_destroy_image(cl->wlist.wlx, cl->tlist[18].img); +	if (cl->tlist[19].img) +		mlx_destroy_image(cl->wlist.wlx, cl->tlist[19].img); +	if (cl->tlist[20].img) +		mlx_destroy_image(cl->wlist.wlx, cl->tlist[20].img); +	if (cl->tlist[21].img) +		mlx_destroy_image(cl->wlist.wlx, cl->tlist[21].img); +	if (cl->tlist[22].img) +		mlx_destroy_image(cl->wlist.wlx, cl->tlist[22].img); +} + +void +	ft_del_tex(t_cub *cl) +{ +	if (cl->wlist.inited) +	{ +		if (cl->tlist[0].img) +			mlx_destroy_image(cl->wlist.wlx, cl->tlist[0].img); +		if (cl->tlist[1].img) +			mlx_destroy_image(cl->wlist.wlx, cl->tlist[1].img); +		if (cl->tlist[2].img) +			mlx_destroy_image(cl->wlist.wlx, cl->tlist[2].img); +		if (cl->tlist[3].img) +			mlx_destroy_image(cl->wlist.wlx, cl->tlist[3].img); +		if (cl->tlist[4].img) +			mlx_destroy_image(cl->wlist.wlx, cl->tlist[4].img); +		ft_del_bonus_tex(cl); +		ft_del_tweap(cl); +		ft_del_tnum(cl); +		ft_del_extra_sprites(cl); +	} +} + | 
