diff options
author | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-03-12 18:56:59 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-03-12 18:56:59 +0100 |
commit | 141fb4d33f73cac99b1b19e475f83fb755f208a2 (patch) | |
tree | e93c2d490440caee29f2c85d86c9dc9bd8512a28 /src/ft_draw_sprite_extra.c | |
parent | kk (diff) | |
download | 42-cub3d-141fb4d33f73cac99b1b19e475f83fb755f208a2.tar.gz 42-cub3d-141fb4d33f73cac99b1b19e475f83fb755f208a2.tar.bz2 42-cub3d-141fb4d33f73cac99b1b19e475f83fb755f208a2.tar.xz 42-cub3d-141fb4d33f73cac99b1b19e475f83fb755f208a2.tar.zst 42-cub3d-141fb4d33f73cac99b1b19e475f83fb755f208a2.zip |
good
Diffstat (limited to 'src/ft_draw_sprite_extra.c')
-rw-r--r-- | src/ft_draw_sprite_extra.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index f6a148c..351ed32 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -42,16 +42,16 @@ void } static void - ft_init_sprite(t_cub *cl, t_sprite *sprite) + ft_init_sprite(t_cub *cl, t_sprite *sprite) { - 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); + 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); } void @@ -64,20 +64,20 @@ void i = 0; j = 0; while (j < cl->mlist.sprite_var - 1) - { - while (i < cl->mlist.sprite_nbr) - { - sprite = cl->sprites[j][i]; - sprite.current_sprite = (j == 0) ? 4 : j + 7; - sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5); - sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5); - ft_init_sprite(cl, &sprite); - ft_sprite_height(cl, &sprite); - ft_sprite_width(cl, &sprite); - ft_draw_sprite(cl, &sprite); - i++; - } - i = 0; - j++; - } + { + while (i < cl->mlist.sprite_nbr) + { + sprite = cl->sprites[j][i]; + sprite.current_sprite = (j == 0) ? 4 : j + 7; + sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5); + sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5); + ft_init_sprite(cl, &sprite); + ft_sprite_height(cl, &sprite); + ft_sprite_width(cl, &sprite); + ft_draw_sprite(cl, &sprite); + i++; + } + i = 0; + j++; + } } |