aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/cub3d_defines.h6
-rw-r--r--inc/cub3d_structs.h3
-rw-r--r--src/ft_del_tex.c9
-rw-r--r--src/ft_floor_cast.c7
-rw-r--r--src/ft_init_sprites.c6
-rw-r--r--src/ft_raycasting.c2
-rw-r--r--src/ft_tex_init.c20
7 files changed, 44 insertions, 9 deletions
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index a479b7f..3d09a81 100644
--- a/inc/cub3d_defines.h
+++ b/inc/cub3d_defines.h
@@ -177,11 +177,11 @@ enum
*/
# define FT_CHRST_VALID_PARSE "RNSEWFCLMT"
-# define FT_CHRST_MAP_ENTRY "0123456789NSEWLT!@+# "
+# define FT_CHRST_MAP_ENTRY "0123456789NSEWLT!@+#e "
# define FT_CHRST_SPRITES "23456789"
# define FT_CHRST_SPAWN "NSEW"
-# define FT_CHRST_MAP_NON_WALL "023456789NESWLT!@+#"
-# define FT_CHRST_COLLISION "123456789 "
+# define FT_CHRST_MAP_NON_WALL "023456789NESWLT!@+#e"
+# define FT_CHRST_COLLISION "123456789e "
# define FT_CHRST_DETECT "1L"
# define FT_CHRST_ITEM "!@+#"
# define FT_CHRST_WEAPONS "!@#"
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index a5c2bcc..3134786 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -227,6 +227,7 @@ typedef struct s_map
typedef struct s_bad_boy
{
int8_t life;
+ int8_t does;
void (*act[5])(struct s_sprite*, struct s_map*);
} t_bad_boy;
@@ -271,7 +272,7 @@ typedef struct s_cub
struct s_img death_screen;
struct s_rgb f_rgb;
struct s_rgb c_rgb;
- struct s_img tlist[23];
+ struct s_img tlist[27];
struct s_img tweap[6];
struct s_img tnum[12];
struct s_sprite **sprites;
diff --git a/src/ft_del_tex.c b/src/ft_del_tex.c
index fc0cf99..5e53366 100644
--- a/src/ft_del_tex.c
+++ b/src/ft_del_tex.c
@@ -20,7 +20,7 @@ static void
uint8_t i;
i = 1;
- while ((i + 2) <= cl->mlist.topsp)
+ while (cl->mlist.sprite_path[i][0])
{
if (cl->tlist[i + 7].img)
mlx_destroy_image(cl->wlist.wlx, cl->tlist[i + 7].img);
@@ -54,6 +54,13 @@ static void
mlx_destroy_image(cl->wlist.wlx, cl->tweap[i].img);
i++;
}
+ i = 23;
+ while (i < 27)
+ {
+ if (cl->tlist[i].img)
+ mlx_destroy_image(cl->wlist.wlx, cl->tlist[i].img);
+ i++;
+ }
}
static void
diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c
index 13a0b54..e80a299 100644
--- a/src/ft_floor_cast.c
+++ b/src/ft_floor_cast.c
@@ -28,10 +28,11 @@ static void
static void
ft_draw_extra_tex(uint8_t tid, uint16_t y, uint16_t x, t_cub *cl)
{
- float dist;
- t_rgb rgb;
+ float dist;
+ t_rgb rgb;
- if ((dist = cl->rlist.row_dist_tab[y]) <= 0)
+ dist = cl->rlist.row_dist_tab[y];
+ if (dist <= 0)
dist = 0.0001;
rgb.b = (uint8_t)cl->tlist[tid].ptr[cl->rlist.fc_tex_x_tab[tid - 6][y][x]
* 4 + 4 * cl->tlist[tid].img_h *
diff --git a/src/ft_init_sprites.c b/src/ft_init_sprites.c
index ee9506f..020f169 100644
--- a/src/ft_init_sprites.c
+++ b/src/ft_init_sprites.c
@@ -32,6 +32,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
*/
int8_t
@@ -57,5 +61,7 @@ int8_t
if (!(*((*sprites) + i) = (t_sprite*)ft_calloc(4, sizeof(t_sprite))))
return (-1);
}
+ if (!(*((*sprites) + 13) = (t_sprite*)ft_calloc(32, sizeof(t_sprite))))
+ return (-1);
return (0);
}
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index 67c3f4e..cc00963 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -31,7 +31,7 @@ static void
!(rl->tex_x_tab = (int32_t*)malloc(x_s * sizeof(int32_t))) ||
!(rl->fc_tex_x_tab = (int32_t***)malloc(2 * sizeof(int32_t**))) ||
!(rl->fc_tex_y_tab = (int32_t***)malloc(2 * sizeof(int32_t**))) ||
- !(rl->row_dist_tab = (float*)malloc(y_s * sizeof(float))))
+ !(rl->row_dist_tab = (float*)ft_calloc(y_s, sizeof(float))))
ft_alloc_error(cl);
x = -1;
while (++x < 2)
diff --git a/src/ft_tex_init.c b/src/ft_tex_init.c
index 1a58421..95c18dd 100644
--- a/src/ft_tex_init.c
+++ b/src/ft_tex_init.c
@@ -41,6 +41,10 @@
** 20: weapon three sprite
** 21: health caption
** 22: ammo caption
+** 23: enemy waiting
+** 24: enemy walking
+** 25: enemy firing
+** 26: enemy dead
*/
static void
@@ -54,6 +58,22 @@ 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