From b2f4e302d39ebfe133530d2cd41ec2f48c8bda58 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 1 Apr 2020 17:32:44 +0200 Subject: Optimization --- src/ft_draw_sprite_extra.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/ft_draw_sprite_extra.c') diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index c9b8b16..d85540d 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -52,21 +52,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); + } } } -- cgit v1.2.3