aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_draw_sprite_extra.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_draw_sprite_extra.c')
-rw-r--r--src/ft_draw_sprite_extra.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c
index c9b8b16..00e295e 100644
--- a/src/ft_draw_sprite_extra.c
+++ b/src/ft_draw_sprite_extra.c
@@ -38,12 +38,13 @@ void
static void
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->invdet = 1.0 /
+ (cl->plist.plane_x * -cl->plist.dir_x
+ - cl->plist.dir_y * cl->plist.plane_y);
+ sprite->transformx = sprite->invdet * (-cl->plist.dir_x * sprite->spritex
+ - cl->plist.dir_y * 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);
}
@@ -52,21 +53,21 @@ void
ft_calc_sprite(t_cub *cl)
{
t_sprite sprite;
- int16_t i;
- int8_t j;
+ int8_t i;
i = -1;
- j = -1;
ft_sort_sprites(cl, -1, -1);
- while (++j < cl->big_t_val)
+ while (++i < cl->big_t_val)
{
- sprite = cl->sprites[(int8_t)cl->big_t[j][2]][(int32_t)cl->big_t[j][3]];
- sprite.current_sprite = (int8_t)cl->big_t[j][1];
- 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_h_w(cl, &sprite);
- ft_draw_sprite(cl, &sprite);
- i = -1;
+ sprite = cl->sprites[(int8_t)cl->big_t[i][2]][(int32_t)cl->big_t[i][3]];
+ if (sprite.s_pos_x != 0)
+ {
+ sprite.current_sprite = (int8_t)cl->big_t[i][1];
+ 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_h_w(cl, &sprite);
+ ft_draw_sprite(cl, &sprite);
+ }
}
}