aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-04 17:31:04 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-04 17:31:04 +0200
commit07ce2cc784a0d420fbc807244847b55389427f6c (patch)
tree9ccd0f73be06633204d80f92c35f191cb9bbd1ff /src
parentMerge branch 'adventures' into bad_boy_select (diff)
download42-cub3d-07ce2cc784a0d420fbc807244847b55389427f6c.tar.gz
42-cub3d-07ce2cc784a0d420fbc807244847b55389427f6c.tar.bz2
42-cub3d-07ce2cc784a0d420fbc807244847b55389427f6c.tar.xz
42-cub3d-07ce2cc784a0d420fbc807244847b55389427f6c.tar.zst
42-cub3d-07ce2cc784a0d420fbc807244847b55389427f6c.zip
Selectable enemy
Diffstat (limited to 'src')
-rw-r--r--src/ft_check_missing_defines.c25
-rw-r--r--src/ft_init_funptr.c3
-rw-r--r--src/ft_init_map.c1
-rw-r--r--src/ft_select_get.c6
-rw-r--r--src/ft_tex_bad_boy_init.c70
-rw-r--r--src/ft_tex_init.c17
6 files changed, 98 insertions, 24 deletions
diff --git a/src/ft_check_missing_defines.c b/src/ft_check_missing_defines.c
index 932bb93..6c616b0 100644
--- a/src/ft_check_missing_defines.c
+++ b/src/ft_check_missing_defines.c
@@ -60,15 +60,30 @@ static int
static int
ft_check_missing_more_tex_defines(t_cub *clist)
{
- if (ft_check_not_found(FT_ENMY_WAIT_PATH) < 0 ||
+ if (clist->mlist.enemy == 1)
+ {
+ if (ft_check_not_found(FT_ENMY_WAIT_PATH) < 0 ||
ft_check_ext(FT_ENMY_WAIT_PATH, ".xpm") < 0 ||
- ft_check_not_found(FT_ENMY_WALK_PATH) < 0 ||
+ ft_check_not_found(FT_ENMY_WALK_PATH) < 0 ||
ft_check_ext(FT_ENMY_WALK_PATH, ".xpm") < 0 ||
- ft_check_not_found(FT_ENMY_FIRE_PATH) < 0 ||
+ ft_check_not_found(FT_ENMY_FIRE_PATH) < 0 ||
ft_check_ext(FT_ENMY_FIRE_PATH, ".xpm") < 0 ||
- ft_check_not_found(FT_ENMY_DEAD_PATH) < 0 ||
+ ft_check_not_found(FT_ENMY_DEAD_PATH) < 0 ||
ft_check_ext(FT_ENMY_DEAD_PATH, ".xpm") < 0)
- return (ft_missing_error(FT_ERR_MISS_ENMY, clist));
+ return (ft_missing_error(FT_ERR_MISS_ENMY, clist));
+ }
+ else
+ {
+ if (ft_check_not_found(FT_CB_WAIT_PATH) < 0 ||
+ ft_check_ext(FT_CB_WAIT_PATH, ".xpm") < 0 ||
+ ft_check_not_found(FT_ENMY_WALK_PATH) < 0 ||
+ ft_check_ext(FT_CB_WALK_PATH, ".xpm") < 0 ||
+ ft_check_not_found(FT_CB_FIRE_PATH) < 0 ||
+ ft_check_ext(FT_CB_FIRE_PATH, ".xpm") < 0 ||
+ ft_check_not_found(FT_CB_DEAD_PATH) < 0 ||
+ ft_check_ext(FT_CB_DEAD_PATH, ".xpm") < 0)
+ return (ft_missing_error(FT_ERR_MISS_ENMY, clist));
+ }
return (ft_check_missing_number_defines(clist));
}
diff --git a/src/ft_init_funptr.c b/src/ft_init_funptr.c
index 99983c6..8f1eba2 100644
--- a/src/ft_init_funptr.c
+++ b/src/ft_init_funptr.c
@@ -37,7 +37,8 @@ void
ft_sprintf(clist->ref[18], "S7");
ft_sprintf(clist->ref[19], "S8");
ft_sprintf(clist->ref[20], "S9");
- ft_bzero(clist->ref[21], 3);
+ ft_sprintf(clist->ref[21], "E2");
+ ft_bzero(clist->ref[22], 3);
}
void
diff --git a/src/ft_init_map.c b/src/ft_init_map.c
index 4d3cc08..07bc8e8 100644
--- a/src/ft_init_map.c
+++ b/src/ft_init_map.c
@@ -92,6 +92,7 @@ int8_t
mlist->isctex = 0;
mlist->isnlvl = 0;
mlist->ismusic = 0;
+ mlist->enemy = 1;
mlist->istraps = 0;
mlist->isheals = 0;
return (ft_init_map_norme(mlist));
diff --git a/src/ft_select_get.c b/src/ft_select_get.c
index 0edc4f2..8c1df38 100644
--- a/src/ft_select_get.c
+++ b/src/ft_select_get.c
@@ -71,12 +71,14 @@ static int8_t
ret = 0;
while (ft_strncmp(words[0], clist->ref[ret], 3) && clist->ref[ret][0])
ret++;
- if (ret == 21)
+ if (ret == 22)
ret = FT_PARSE_END_RET;
ret = ft_check_exists(ret, clist);
ret = ft_check_exists_two(ret, clist);
if (ret > 13 && ret < 21)
ret = 5;
+ if (ret == 21)
+ clist->mlist.enemy = 2;
return (ret);
}
@@ -90,7 +92,7 @@ int8_t
ft_free_words(words);
return (FT_PARSE_END_RET);
}
- if (id < 0 || clist->get_ptr[id](words, clist) < 0)
+ if (id < 0 || (id != 21 && clist->get_ptr[id](words, clist) < 0))
{
ft_free_words(words);
return ((id < 0) ? (-2) : (-1));
diff --git a/src/ft_tex_bad_boy_init.c b/src/ft_tex_bad_boy_init.c
new file mode 100644
index 0000000..748d680
--- /dev/null
+++ b/src/ft_tex_bad_boy_init.c
@@ -0,0 +1,70 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_tex_bad_boy_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 <cub3d.h>
+#include <stdint.h>
+#include <mlx.h>
+
+static void
+ ft_tex_skel(t_cub *cl)
+{
+ cl->tlist[23].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_ENMY_WAIT_PATH, &cl->tlist[23].img_w, &cl->tlist[23].img_h);
+ cl->tlist[23].ptr = mlx_get_data_addr(cl->tlist[23].img,
+ &cl->tlist[23].bpp, &cl->tlist[23].sizeline, &cl->tlist[23].endian);
+ cl->tlist[24].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_ENMY_WALK_PATH, &cl->tlist[24].img_w, &cl->tlist[24].img_h);
+ cl->tlist[24].ptr = mlx_get_data_addr(cl->tlist[24].img,
+ &cl->tlist[24].bpp, &cl->tlist[24].sizeline, &cl->tlist[24].endian);
+ cl->tlist[25].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_ENMY_FIRE_PATH, &cl->tlist[25].img_w, &cl->tlist[25].img_h);
+ cl->tlist[25].ptr = mlx_get_data_addr(cl->tlist[25].img,
+ &cl->tlist[25].bpp, &cl->tlist[25].sizeline, &cl->tlist[25].endian);
+ cl->tlist[26].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_ENMY_DEAD_PATH, &cl->tlist[26].img_w, &cl->tlist[26].img_h);
+ cl->tlist[26].ptr = mlx_get_data_addr(cl->tlist[26].img,
+ &cl->tlist[26].bpp, &cl->tlist[26].sizeline, &cl->tlist[26].endian);
+}
+
+static void
+ ft_tex_cowboy(t_cub *cl)
+{
+ cl->tlist[23].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_CB_WAIT_PATH, &cl->tlist[23].img_w, &cl->tlist[23].img_h);
+ cl->tlist[23].ptr = mlx_get_data_addr(cl->tlist[23].img,
+ &cl->tlist[23].bpp, &cl->tlist[23].sizeline, &cl->tlist[23].endian);
+ cl->tlist[24].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_CB_WALK_PATH, &cl->tlist[24].img_w, &cl->tlist[24].img_h);
+ cl->tlist[24].ptr = mlx_get_data_addr(cl->tlist[24].img,
+ &cl->tlist[24].bpp, &cl->tlist[24].sizeline, &cl->tlist[24].endian);
+ cl->tlist[25].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_CB_FIRE_PATH, &cl->tlist[25].img_w, &cl->tlist[25].img_h);
+ cl->tlist[25].ptr = mlx_get_data_addr(cl->tlist[25].img,
+ &cl->tlist[25].bpp, &cl->tlist[25].sizeline, &cl->tlist[25].endian);
+ cl->tlist[26].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ FT_CB_DEAD_PATH, &cl->tlist[26].img_w, &cl->tlist[26].img_h);
+ cl->tlist[26].ptr = mlx_get_data_addr(cl->tlist[26].img,
+ &cl->tlist[26].bpp, &cl->tlist[26].sizeline, &cl->tlist[26].endian);
+}
+
+void
+ ft_tex_bad_boy_init(t_cub *cl)
+{
+ if (cl->mlist.enemy == 1)
+ {
+ ft_tex_skel(cl);
+ }
+ else
+ {
+ ft_tex_cowboy(cl);
+ }
+}
diff --git a/src/ft_tex_init.c b/src/ft_tex_init.c
index 95c18dd..d629f76 100644
--- a/src/ft_tex_init.c
+++ b/src/ft_tex_init.c
@@ -58,22 +58,6 @@ static void
FT_CAP_AMMO_PATH, &cl->tlist[22].img_w, &cl->tlist[22].img_h);
cl->tlist[22].ptr = mlx_get_data_addr(cl->tlist[22].img,
&cl->tlist[22].bpp, &cl->tlist[22].sizeline, &cl->tlist[22].endian);
- cl->tlist[23].img = mlx_xpm_file_to_image(cl->wlist.wlx,
- FT_ENMY_WAIT_PATH, &cl->tlist[23].img_w, &cl->tlist[23].img_h);
- cl->tlist[23].ptr = mlx_get_data_addr(cl->tlist[23].img,
- &cl->tlist[23].bpp, &cl->tlist[23].sizeline, &cl->tlist[23].endian);
- cl->tlist[24].img = mlx_xpm_file_to_image(cl->wlist.wlx,
- FT_ENMY_WALK_PATH, &cl->tlist[24].img_w, &cl->tlist[24].img_h);
- cl->tlist[24].ptr = mlx_get_data_addr(cl->tlist[24].img,
- &cl->tlist[24].bpp, &cl->tlist[24].sizeline, &cl->tlist[24].endian);
- cl->tlist[25].img = mlx_xpm_file_to_image(cl->wlist.wlx,
- FT_ENMY_FIRE_PATH, &cl->tlist[25].img_w, &cl->tlist[25].img_h);
- cl->tlist[25].ptr = mlx_get_data_addr(cl->tlist[25].img,
- &cl->tlist[25].bpp, &cl->tlist[25].sizeline, &cl->tlist[25].endian);
- cl->tlist[26].img = mlx_xpm_file_to_image(cl->wlist.wlx,
- FT_ENMY_DEAD_PATH, &cl->tlist[26].img_w, &cl->tlist[26].img_h);
- cl->tlist[26].ptr = mlx_get_data_addr(cl->tlist[26].img,
- &cl->tlist[26].bpp, &cl->tlist[26].sizeline, &cl->tlist[26].endian);
}
static void
@@ -96,6 +80,7 @@ static void
cl->tlist[20].ptr = mlx_get_data_addr(cl->tlist[20].img,
&cl->tlist[20].bpp, &cl->tlist[20].sizeline, &cl->tlist[20].endian);
ft_wall_tex_init_even_more_bonus(cl);
+ ft_tex_bad_boy_init(cl);
cl->walltexgood = 1;
if (cl->mlist.sprite_var > 1)
ft_next_sprite_init(cl);