aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_draw_sprite_extra.c
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2020-03-09 21:03:16 +0100
committersalaaad2 <arthurdurant263@gmail.com>2020-03-09 21:03:16 +0100
commit02955219fd0a1bd42e3009f77911f5f258d59d34 (patch)
treef7e3921630702db9aa3465e17e7cb3837d3a38e4 /src/ft_draw_sprite_extra.c
parentgang_2 (diff)
download42-cub3d-02955219fd0a1bd42e3009f77911f5f258d59d34.tar.gz
42-cub3d-02955219fd0a1bd42e3009f77911f5f258d59d34.tar.bz2
42-cub3d-02955219fd0a1bd42e3009f77911f5f258d59d34.tar.xz
42-cub3d-02955219fd0a1bd42e3009f77911f5f258d59d34.tar.zst
42-cub3d-02955219fd0a1bd42e3009f77911f5f258d59d34.zip
get next sprite
Diffstat (limited to 'src/ft_draw_sprite_extra.c')
-rw-r--r--src/ft_draw_sprite_extra.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c
index 73b8959..f3cdf08 100644
--- a/src/ft_draw_sprite_extra.c
+++ b/src/ft_draw_sprite_extra.c
@@ -45,24 +45,31 @@ void
{
t_sprite sprite;
int32_t i;
+ int32_t j;
i = 0;
- while (i < cl->mlist.sprite_nbr)
- {
- sprite = cl->sprites[i];
- sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5);
- sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5);
- sprite.invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_y
- - cl->plist.dir_x * cl->plist.plane_y);
- sprite.transformx = sprite.invdet * (cl->plist.dir_y * sprite.spritex
- - cl->plist.dir_x * sprite.spritey);
- sprite.transformy = sprite.invdet * (-cl->plist.plane_y * sprite.spritex
- + cl->plist.plane_x * sprite.spritey);
- sprite.spritescreenx = (int)(cl->wlist.x_size / 2) *
- (1 + sprite.transformx / sprite.transformy);
- ft_sprite_height(cl, &sprite);
- ft_sprite_width(cl, &sprite);
- ft_draw_sprite(cl, &sprite);
- i++;
- }
+ j = 0;
+ while (j < cl->mlist.sprite_var)
+ {
+ while (i < cl->mlist.sprite_nbr)
+ {
+ sprite = cl->sprites[j][i];
+ sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5);
+ sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5);
+ sprite.invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_y
+ - cl->plist.dir_x * cl->plist.plane_y);
+ sprite.transformx = sprite.invdet * (cl->plist.dir_y * sprite.spritex
+ - cl->plist.dir_x * sprite.spritey);
+ sprite.transformy = sprite.invdet * (-cl->plist.plane_y * sprite.spritex
+ + cl->plist.plane_x * sprite.spritey);
+ sprite.spritescreenx = (int)(cl->wlist.x_size / 2) *
+ (1 + sprite.transformx / sprite.transformy);
+ ft_sprite_height(cl, &sprite);
+ ft_sprite_width(cl, &sprite);
+ ft_draw_sprite(cl, &sprite);
+ i++;
+ }
+ i = 0;
+ j++;
+ }
}