aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ft_check_missing.c3
-rw-r--r--src/ft_death_screen.c59
-rw-r--r--src/ft_suffer_animation.c8
3 files changed, 66 insertions, 4 deletions
diff --git a/src/ft_check_missing.c b/src/ft_check_missing.c
index 617e8f5..a17bdea 100644
--- a/src/ft_check_missing.c
+++ b/src/ft_check_missing.c
@@ -82,6 +82,9 @@ static int
return (ft_missing_error(FT_ERR_MISS_NLVL_PATH, clist));
if (clist->mlist.istraps && !clist->mlist.traps_path[0])
return (ft_missing_error(FT_ERR_MISS_TRAP, clist));
+ if (ft_check_not_found(FT_DEATH_SCREEN_PATH) < 0 ||
+ ft_check_ext(FT_DEATH_SCREEN_PATH, ".xpm") < 0)
+ return (ft_missing_error(FT_ERR_MISS_DEATH_SCREEN, clist));
return (ft_check_missing_sprites(clist));
}
diff --git a/src/ft_death_screen.c b/src/ft_death_screen.c
new file mode 100644
index 0000000..80ba23c
--- /dev/null
+++ b/src/ft_death_screen.c
@@ -0,0 +1,59 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_death_screen.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 17:20:05 by rbousset #+# #+# */
+/* Updated: 2020/02/14 17:20:06 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <cub3d.h>
+#include <mlx.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static void
+ ft_draw_death_screen(t_cub *cl)
+{
+ uint16_t x;
+ uint16_t y;
+
+ x = 0;
+ y = 0;
+ while (x < cl->wlist.x_size)
+ {
+ while (y < cl->wlist.y_size)
+ {
+ /* cl->death_screen.tex_x = ; */
+ /* cl->death_screen.tex_y = ; */
+ x++;
+ }
+ x = 0;
+ y++;
+ }
+}
+
+void
+ ft_death_screen(t_cub *cl)
+{
+ cl->death_screen.img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_DEATH_SCREEN_PATH, &cl->death_screen.img_w, &cl->death_screen.img_h);
+ cl->death_screen.ptr = mlx_get_data_addr(cl->death_screen.img,
+ &cl->death_screen.bpp, &cl->death_screen.sizeline,
+ &cl->death_screen.endian);
+ cl->img.img = mlx_new_image(cl->wlist.wlx,
+ cl->wlist.x_size, cl->wlist.y_size);
+ cl->img.ptr = mlx_get_data_addr(cl->img.img, &cl->img.bpp,
+ &cl->img.sizeline, &cl->img.endian);
+ ft_draw_death_screen(cl);
+ mlx_put_image_to_window(cl->wlist.wlx, cl->wlist.winptr,
+ cl->img.img, 0, 0);
+ ft_hooks_and_loops(&cl->wlist, cl);
+ mlx_destroy_image(cl->wlist.wlx, cl->img.img);
+ mlx_destroy_image(cl->wlist.wlx, cl->death_screen.img);
+ while (1)
+ sleep(4);
+}
diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c
index 6eacdf1..c5187f9 100644
--- a/src/ft_suffer_animation.c
+++ b/src/ft_suffer_animation.c
@@ -40,9 +40,9 @@ void
cl->plist.life -= 20;
if (cl->plist.life <= 0)
{
- ft_warp_level(cl->mlist.filename, cl);
+ /* ft_warp_level(cl->mlist.filename, cl); */
ft_sfx_death(cl);
- /* TODO death screen here */
+ ft_death_screen(cl);
}
else
ft_sfx_trap(cl);
@@ -73,9 +73,9 @@ void
cl->plist.life -= 20;
if (cl->plist.life <= 0)
{
- ft_warp_level(cl->mlist.filename, cl);
+ /* ft_warp_level(cl->mlist.filename, cl); */
ft_sfx_death(cl);
- /* TODO death screen here */
+ ft_death_screen(cl);
}
else
ft_sfx_trap(cl);