aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_del_tex.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-22 15:25:01 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-22 15:25:01 +0100
commitba7cbd8dbffac2b75ccac01d628ca493426ecf70 (patch)
treef2a09778ada9033522bf36206158c6130eb85365 /src/ft_del_tex.c
parentNormed so far (diff)
download42-cub3d-ba7cbd8dbffac2b75ccac01d628ca493426ecf70.tar.gz
42-cub3d-ba7cbd8dbffac2b75ccac01d628ca493426ecf70.tar.bz2
42-cub3d-ba7cbd8dbffac2b75ccac01d628ca493426ecf70.tar.xz
42-cub3d-ba7cbd8dbffac2b75ccac01d628ca493426ecf70.tar.zst
42-cub3d-ba7cbd8dbffac2b75ccac01d628ca493426ecf70.zip
Pretty bav
Diffstat (limited to 'src/ft_del_tex.c')
-rw-r--r--src/ft_del_tex.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/ft_del_tex.c b/src/ft_del_tex.c
new file mode 100644
index 0000000..839387a
--- /dev/null
+++ b/src/ft_del_tex.c
@@ -0,0 +1,101 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* 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 < 11)
+ {
+ 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 < 4)
+ {
+ 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);
+}
+
+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);
+ }
+}
+