aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--inc/cub3d.h1
-rw-r--r--inc/cub3d_defines.h1
-rw-r--r--inc/cub3d_structs.h2
-rw-r--r--map/map_seven.cub2
-rw-r--r--src/ft_big_t.c4
-rw-r--r--src/ft_del_sprites_lists.c1
-rw-r--r--src/ft_draw_sprite_extra.c1
-rw-r--r--src/ft_get_sprite_spawns.c10
-rw-r--r--src/ft_init_bad_boys.c37
10 files changed, 56 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 59b009e..cdc7f5b 100644
--- a/Makefile
+++ b/Makefile
@@ -126,6 +126,7 @@ SRCS_NAME += ft_castray_loop.c
SRCS_NAME += ft_sort_s_t.c
SRCS_NAME += ft_big_t.c
SRCS_NAME += ft_time.c
+SRCS_NAME += ft_init_bad_boys.c
#--------------------------------------------------------------------------------------------------#
SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME})
#--------------------------------------------------------------------------------------------------#
diff --git a/inc/cub3d.h b/inc/cub3d.h
index 02cb20d..85e2ab3 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -38,6 +38,7 @@ t_rgb ft_hex_to_og_rgb(uint32_t color);
int8_t ft_init_sfx(t_cub *cl);
int8_t ft_init_sprites(t_sprite ***sprites);
int8_t ft_init_weaps(t_sprite ***weaps);
+int8_t ft_init_bad_boys(t_cub *cl);
/*
** ====== HOOKS ======
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index 3d09a81..e47c1f7 100644
--- a/inc/cub3d_defines.h
+++ b/inc/cub3d_defines.h
@@ -242,6 +242,7 @@ enum
# define FT_ERR_TOO_MUCH_W_ONE "too much weapon one, limit is 4"
# define FT_ERR_TOO_MUCH_W_TWO "too much weapon two, limit is 4"
# define FT_ERR_TOO_MUCH_W_THREE "too much weapon three, limit is 4"
+# define FT_ERR_TOO_MUCH_ENMY "too much enemy, limit is 32"
/*
** ====== MISSING ERROR MSG ======
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index 3134786..329f8bb 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -228,7 +228,7 @@ typedef struct s_bad_boy
{
int8_t life;
int8_t does;
- void (*act[5])(struct s_sprite*, struct s_map*);
+ void (*act[3])(struct s_sprite*, struct s_map*);
} t_bad_boy;
typedef struct s_cub
diff --git a/map/map_seven.cub b/map/map_seven.cub
index 57b2576..a72ca1c 100644
--- a/map/map_seven.cub
+++ b/map/map_seven.cub
@@ -13,7 +13,7 @@ C 150,150,150
1111111111111111111
1000000000000000001
1000000000000000001
-1000000000000000001
+10000000e0000000001
1000000000000000001
1000000000000000001
1000000000000000001
diff --git a/src/ft_big_t.c b/src/ft_big_t.c
index e01bed7..b4d7e52 100644
--- a/src/ft_big_t.c
+++ b/src/ft_big_t.c
@@ -27,8 +27,10 @@ static int8_t
return (15);
else if (st_o == 9)
return (17);
- else if (st_o >= 10)
+ else if (st_o >= 10 && st_o <= 12)
return (st_o + 8);
+ else if (st_o == 13)
+ return (23);
return (0);
}
diff --git a/src/ft_del_sprites_lists.c b/src/ft_del_sprites_lists.c
index 6a1a662..b7a854d 100644
--- a/src/ft_del_sprites_lists.c
+++ b/src/ft_del_sprites_lists.c
@@ -19,6 +19,7 @@ void
{
int8_t i;
+ ft_memdel((void*)&clist->bad_boy);
i = 0;
while (i < FT_TOTAL_SPRT)
{
diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c
index 43e69e3..c9b8b16 100644
--- a/src/ft_draw_sprite_extra.c
+++ b/src/ft_draw_sprite_extra.c
@@ -48,7 +48,6 @@ static void
(1 + sprite->transformx / sprite->transformy);
}
-#include <libft.h>
void
ft_calc_sprite(t_cub *cl)
{
diff --git a/src/ft_get_sprite_spawns.c b/src/ft_get_sprite_spawns.c
index 21c4cb8..a573593 100644
--- a/src/ft_get_sprite_spawns.c
+++ b/src/ft_get_sprite_spawns.c
@@ -30,6 +30,10 @@
** 10: weapon one - tlist[18] - 4
** 11: weapon two - tlist[19] - 4
** 12: weapon three - tlist[20] - 4
+** 13: enemy - tlist[23] |
+** '- - - - - - - tlist[24] |
+** '- - - - - - - tlist[25] |
+** '- - - - - - - tlist[26] - 32
*/
static void
@@ -47,6 +51,8 @@ static void
ft_map_error(FT_ERR_TOO_MUCH_W_TWO, cl);
else if (s_n == 12 && cl->mlist.sprite_nbr[s_n] > 4)
ft_map_error(FT_ERR_TOO_MUCH_W_THREE, cl);
+ else if (s_n == 13 && cl->mlist.sprite_nbr[s_n] > 32)
+ ft_map_error(FT_ERR_TOO_MUCH_ENMY, cl);
}
static int8_t
@@ -62,6 +68,10 @@ static int8_t
return (ft_get_next_sprite(cl, 11, '@', 0));
if (s_n + 1 == 12)
return (ft_get_next_sprite(cl, 12, '#', 0));
+ if (s_n + 1 == 13)
+ return (ft_get_next_sprite(cl, 13, 'e', 0));
+ if (cl->mlist.sprite_nbr[13] > 0)
+ return (ft_init_bad_boys(cl));
return (0);
}
diff --git a/src/ft_init_bad_boys.c b/src/ft_init_bad_boys.c
new file mode 100644
index 0000000..8ddc9a5
--- /dev/null
+++ b/src/ft_init_bad_boys.c
@@ -0,0 +1,37 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_init_bad_boys.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 17:28:51 by rbousset #+# #+# */
+/* Updated: 2020/02/14 17:28:51 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+#include <cub3d.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+int8_t
+ ft_init_bad_boys(t_cub *cl)
+{
+ int8_t i;
+
+ if (!(cl->bad_boy = (t_bad_boy*)malloc(cl->mlist.sprite_nbr[13]
+ * sizeof(t_bad_boy))))
+ return (ft_alloc_error(cl));
+ i = 0;
+ while (i < cl->mlist.sprite_nbr[13])
+ {
+ cl->bad_boy[i].life = 5;
+ cl->bad_boy[i].does = 0;
+ cl->bad_boy[i].act[0] = ft_bb_wait;
+ cl->bad_boy[i].act[1] = ft_bb_walk;
+ cl->bad_boy[i].act[2] = ft_bb_fire;
+ i++;
+ }
+ return (0);
+}