aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ft_check_missing.c12
-rw-r--r--src/ft_tex_init.c49
-rw-r--r--src/ft_tex_weap_init.c46
-rw-r--r--src/ft_warp_level.c1
-rw-r--r--src/main.c1
5 files changed, 86 insertions, 23 deletions
diff --git a/src/ft_check_missing.c b/src/ft_check_missing.c
index fcebf3f..4b4a3ef 100644
--- a/src/ft_check_missing.c
+++ b/src/ft_check_missing.c
@@ -40,6 +40,15 @@ static int
{
int8_t i;
+ if (ft_check_not_found(FT_WEAPON_ONE_SPR_PATH) < 0 ||
+ ft_check_ext(FT_WEAPON_ONE_SPR_PATH, ".xpm") < 0)
+ return (ft_missing_error(FT_ERR_MISS_W_ONE_SPR, clist));
+ if (ft_check_not_found(FT_WEAPON_TWO_SPR_PATH) < 0 ||
+ ft_check_ext(FT_WEAPON_TWO_SPR_PATH, ".xpm") < 0)
+ return (ft_missing_error(FT_ERR_MISS_W_TWO_SPR, clist));
+ if (ft_check_not_found(FT_HEAL_PACK_PATH) < 0 ||
+ ft_check_ext(FT_HEAL_PACK_PATH, ".xpm") < 0)
+ return (ft_missing_error(FT_ERR_MISS_HEAL_PACK, clist));
i = 0;
while ((i + 2) <= clist->mlist.topsp)
{
@@ -71,9 +80,6 @@ static int
if (ft_check_not_found(FT_WEAPON_TWO_FIRE_PATH) < 0 ||
ft_check_ext(FT_WEAPON_TWO_FIRE_PATH, ".xpm") < 0)
return (ft_missing_error(FT_ERR_MISS_W_TWO_FIRE, clist));
- if (ft_check_not_found(FT_HEAL_PACK_PATH) < 0 ||
- ft_check_ext(FT_HEAL_PACK_PATH, ".xpm") < 0)
- return (ft_missing_error(FT_ERR_MISS_HEAL_PACK, clist));
return (ft_check_missing_sprites(clist));
}
diff --git a/src/ft_tex_init.c b/src/ft_tex_init.c
index 6486e87..34f9fb9 100644
--- a/src/ft_tex_init.c
+++ b/src/ft_tex_init.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_basic_keys.c :+: :+: :+: */
+/* ft_tex_init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fmoenne- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -13,30 +13,31 @@
#include <libft.h>
#include <cub3d.h>
#include <stdint.h>
-#include <stdio.h>
#include <mlx.h>
/*
** tlist[] index summary
** ---------------------
-** 0 : no
-** 1 : so
-** 2 : ea
-** 3 : we
-** 4 : sprite 2
-** 5 : new level door
-** 6 : floor
-** 7 : ceil / skybox
-** 8 : sprite 3
-** 9 : sprite 4
-** 10 : sprite 5
-** 11 : sprite 6
-** 12 : sprite 7
-** 13 : sprite 8
-** 14 : sprite 9
-** 15 : trap
-** 16 : HUD back
-** 17 : heal pack
+** 0: no
+** 1: so
+** 2: ea
+** 3: we
+** 4: sprite 2
+** 5: new level door
+** 6: floor
+** 7: ceil / skybox
+** 8: sprite 3
+** 9: sprite 4
+** 10: sprite 5
+** 11: sprite 6
+** 12: sprite 7
+** 13: sprite 8
+** 14: sprite 9
+** 15: trap
+** 16: HUD back
+** 17: heal pack
+** 18: weapon one sprite
+** 19: weapon two sprite
*/
static void
@@ -78,6 +79,14 @@ static void
FT_HUD_BACK_PATH, &cl->tlist[16].img_w, &cl->tlist[16].img_h);
cl->tlist[16].ptr = mlx_get_data_addr(cl->tlist[16].img,
&cl->tlist[16].bpp, &cl->tlist[16].sizeline, &cl->tlist[16].endian);
+ cl->tlist[18].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_WEAPON_ONE_SPR_PATH, &cl->tlist[18].img_w, &cl->tlist[18].img_h);
+ cl->tlist[18].ptr = mlx_get_data_addr(cl->tlist[18].img,
+ &cl->tlist[18].bpp, &cl->tlist[18].sizeline, &cl->tlist[18].endian);
+ cl->tlist[19].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_WEAPON_TWO_SPR_PATH, &cl->tlist[19].img_w, &cl->tlist[19].img_h);
+ cl->tlist[19].ptr = mlx_get_data_addr(cl->tlist[19].img,
+ &cl->tlist[19].bpp, &cl->tlist[19].sizeline, &cl->tlist[19].endian);
cl->walltexgood = 1;
if (cl->mlist.sprite_var > 1)
ft_next_sprite_init(cl);
diff --git a/src/ft_tex_weap_init.c b/src/ft_tex_weap_init.c
new file mode 100644
index 0000000..ac78de9
--- /dev/null
+++ b/src/ft_tex_weap_init.c
@@ -0,0 +1,46 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_tex_weap_init.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: fmoenne- <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 17:43:55 by fmoenne- #+# #+# */
+/* Updated: 2020/02/14 17:43:56 by fmoenne- ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+#include <cub3d.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <mlx.h>
+
+/*
+** tweap[] index summary
+** 0: weapon one
+** 1: weapon one fire
+** 2: weapon two
+** 3: weapon two fire
+*/
+
+void
+ ft_weap_tex_init(t_cub *cl)
+{
+ cl->tweap[0].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_WEAPON_ONE_PATH, &cl->tweap[0].img_w, &cl->tweap[0].img_h);
+ cl->tweap[0].ptr = mlx_get_data_addr(cl->tweap[0].img,
+ &cl->tweap[0].bpp, &cl->tweap[0].sizeline, &cl->tweap[0].endian);
+ cl->tweap[1].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_WEAPON_ONE_FIRE_PATH, &cl->tweap[1].img_w, &cl->tweap[1].img_h);
+ cl->tweap[1].ptr = mlx_get_data_addr(cl->tweap[1].img,
+ &cl->tweap[1].bpp, &cl->tweap[1].sizeline, &cl->tweap[1].endian);
+ cl->tweap[2].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_WEAPON_TWO_PATH, &cl->tweap[2].img_w, &cl->tweap[2].img_h);
+ cl->tweap[2].ptr = mlx_get_data_addr(cl->tweap[2].img,
+ &cl->tweap[2].bpp, &cl->tweap[2].sizeline, &cl->tweap[2].endian);
+ cl->tweap[3].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_WEAPON_TWO_FIRE_PATH, &cl->tweap[3].img_w, &cl->tweap[3].img_h);
+ cl->tweap[3].ptr = mlx_get_data_addr(cl->tweap[3].img,
+ &cl->tweap[3].bpp, &cl->tweap[3].sizeline, &cl->tweap[3].endian);
+}
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c
index a2b6006..09f0322 100644
--- a/src/ft_warp_level.c
+++ b/src/ft_warp_level.c
@@ -116,6 +116,7 @@ int8_t
if (isoldmus)
ft_memdel((void*)&tmp_mup);
ft_wall_tex_init(cl);
+ ft_weap_tex_init(cl);
ft_memdel((void*)&next_path);
return (0);
}
diff --git a/src/main.c b/src/main.c
index a1c9a8c..623787b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -30,6 +30,7 @@ int
if (ft_init_winlx(clist) < 0)
return (ft_exit(FT_RET_FAILED_MLX, clist));
ft_wall_tex_init(clist);
+ ft_weap_tex_init(clist);
ft_use_args(argc, argv, envp, clist);
return (FT_RET_FINE);
}