aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-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
5 files changed, 39 insertions, 5 deletions
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