aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--Makefile1
-rw-r--r--bart.jpegbin265103 -> 0 bytes
-rw-r--r--hol.jpegbin93795 -> 0 bytes
-rw-r--r--inc/cub3d.h1
-rw-r--r--inc/cub3d_defines.h12
-rw-r--r--inc/cub3d_structs.h3
-rw-r--r--map/adv_one.cub2
-rw-r--r--map/adv_three.cub3
-rw-r--r--map/adv_two.cub2
-rw-r--r--map/adv_up1.cub1
-rw-r--r--map/adv_up2.cub1
-rw-r--r--minilibx_linux/Makefile.gen2
-rw-r--r--minilibx_linux/test/Makefile.gen2
-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
19 files changed, 120 insertions, 32 deletions
diff --git a/Makefile b/Makefile
index 43c90e2..bc05164 100644
--- a/Makefile
+++ b/Makefile
@@ -135,6 +135,7 @@ SRCS_NAME += ft_sfx_bb_death.c
SRCS_NAME += ft_sfx_bb_scream.c
SRCS_NAME += ft_sfx_bb_fire.c
SRCS_NAME += ft_can_it_shoot.c
+SRCS_NAME += ft_tex_bad_boy_init.c
#--------------------------------------------------------------------------------------------------#
SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME})
#--------------------------------------------------------------------------------------------------#
diff --git a/bart.jpeg b/bart.jpeg
deleted file mode 100644
index c7ea3ed..0000000
--- a/bart.jpeg
+++ /dev/null
Binary files differ
diff --git a/hol.jpeg b/hol.jpeg
deleted file mode 100644
index bbecd40..0000000
--- a/hol.jpeg
+++ /dev/null
Binary files differ
diff --git a/inc/cub3d.h b/inc/cub3d.h
index bfc0299..15d9ef0 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -68,6 +68,7 @@ void ft_wall_tex_init(t_cub *cl);
void ft_next_sprite_init(t_cub *cl);
void ft_weap_tex_init(t_cub *cl);
void ft_num_tex_init(t_cub *cl);
+void ft_tex_bad_boy_init(t_cub *cl);
/*
** ====== DRAW ======
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index da371a6..2829095 100644
--- a/inc/cub3d_defines.h
+++ b/inc/cub3d_defines.h
@@ -124,10 +124,14 @@ enum
# define FT_WEAPON_TWO_FIRE_PATH "./media/img/weapons/colt_w_fire.xpm"
# define FT_WEAPON_THREE_PATH "./media/img/weapons/double_b_w.xpm"
# define FT_WEAPON_THREE_FIRE_PATH "./media/img/weapons/double_b_w_fire.xpm"
-# define FT_ENMY_WAIT_PATH "./media/img/sprites/chr_cb1.xpm"
-# define FT_ENMY_WALK_PATH "./media/img/sprites/chr_cb2.xpm"
-# define FT_ENMY_FIRE_PATH "./media/img/sprites/chr_cb3.xpm"
-# define FT_ENMY_DEAD_PATH "./media/img/sprites/chr_cbd.xpm"
+# define FT_ENMY_WAIT_PATH "./media/img/sprites/skel_waiting.xpm"
+# define FT_ENMY_WALK_PATH "./media/img/sprites/skel_walking.xpm"
+# define FT_ENMY_FIRE_PATH "./media/img/sprites/skel_firing.xpm"
+# define FT_ENMY_DEAD_PATH "./media/img/sprites/skel_dead.xpm"
+# define FT_CB_WAIT_PATH "./media/img/sprites/chr_cb1.xpm"
+# define FT_CB_WALK_PATH "./media/img/sprites/chr_cb2.xpm"
+# define FT_CB_FIRE_PATH "./media/img/sprites/chr_cb3.xpm"
+# define FT_CB_DEAD_PATH "./media/img/sprites/chr_cbd.xpm"
# define FT_HEAL_PACK_PATH "./media/img/sprites/sr_hp.xpm"
# define FT_ZER_PATH "./media/img/hud/zero.xpm"
# define FT_ONE_PATH "./media/img/hud/one.xpm"
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index 3eabcad..8d22b86 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -203,6 +203,7 @@ typedef struct s_map
size_t line_chk;
size_t map_start;
uint8_t isspawn;
+ uint8_t enemy;
uint8_t isnlvl;
uint8_t ismusic;
uint8_t isftex;
@@ -259,7 +260,7 @@ typedef struct s_cub
uint16_t ammo_num_w;
int (*key_ptr[6])(struct s_cub*);
int8_t (*get_ptr[14])(char**, struct s_cub*);
- char ref[22][3];
+ char ref[23][3];
struct s_win wlist;
struct s_player plist;
struct s_map mlist;
diff --git a/map/adv_one.cub b/map/adv_one.cub
index 8ab55ba..3cf440c 100644
--- a/map/adv_one.cub
+++ b/map/adv_one.cub
@@ -16,6 +16,8 @@ LT ./media/img/tex/sal_door.xpm
MU ./media/sound/big_iron.wav
+E2
+
1111111111111111111
1000000000000000211
1000000000000000211
diff --git a/map/adv_three.cub b/map/adv_three.cub
index 4585d32..301fd4d 100644
--- a/map/adv_three.cub
+++ b/map/adv_three.cub
@@ -15,12 +15,13 @@ L ./map/map_seven.cub
LT ./media/img/tex/hol.xpm
MU ./media/sound/big_iron.wav
+E2
1111111111111111111
1000000000000+11111
1000000000000000+11
1000000000000000011
-1E@0000e000000000L1
+1E00000e000000000L1
1000000000000000011
1000000000000000011
1000000000000000+11
diff --git a/map/adv_two.cub b/map/adv_two.cub
index 787062b..ae3af9c 100644
--- a/map/adv_two.cub
+++ b/map/adv_two.cub
@@ -16,6 +16,8 @@ LT ./media/img/tex/stairs.xpm
MU ./media/sound/big_iron.wav
+E2
+
1111111111111111111
1000000000000+11111
1000000000000000+11
diff --git a/map/adv_up1.cub b/map/adv_up1.cub
index 7bd7ffa..de68581 100644
--- a/map/adv_up1.cub
+++ b/map/adv_up1.cub
@@ -15,6 +15,7 @@ L ./map/adv_up2.cub
LT ./media/img/tex/porte.xpm
MU ./media/sound/big_iron.wav
+E2
1111111111111111111
100000000000+W01111
diff --git a/map/adv_up2.cub b/map/adv_up2.cub
index 1cf88c4..ee4bc40 100644
--- a/map/adv_up2.cub
+++ b/map/adv_up2.cub
@@ -17,6 +17,7 @@ LT ./media/img/tex/porte.xpm
S3 ./media/img/sprites/chr_cgl.xpm
MU ./media/sound/big_iron.wav
+E2
111111111111
1L1++++++++1
diff --git a/minilibx_linux/Makefile.gen b/minilibx_linux/Makefile.gen
index e5e2ce0..5e2b3c1 100644
--- a/minilibx_linux/Makefile.gen
+++ b/minilibx_linux/Makefile.gen
@@ -1,5 +1,5 @@
INC=/usr/include
-HT=Linux
+HT=x86_64
DOCP=do_cp
##
## Makefile for MiniLibX in /home/boulon/work/c/raytraceur/minilibx
diff --git a/minilibx_linux/test/Makefile.gen b/minilibx_linux/test/Makefile.gen
index 7c67f50..c13f70c 100644
--- a/minilibx_linux/test/Makefile.gen
+++ b/minilibx_linux/test/Makefile.gen
@@ -1,5 +1,5 @@
INC=/usr/include
-HT=Linux
+HT=x86_64
DOCP=do_cp
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);