diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_draw_sprite_extra.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index e592da0..5133231 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -47,25 +47,38 @@ static void (1 + sprite->transformx / sprite->transformy); } +static int8_t + ft_set_current_sprite(t_cub *cl, int8_t j) +{ + const int8_t st_o = cl->mlist.st_o[j]; + + if (st_o == 0) + return (4); + else if (st_o >= 1 && st_o <= 7) + return (st_o + 7); + else if (st_o == 8) + return (15); + return (0); +} + void ft_calc_sprite(t_cub *cl) { t_sprite sprite; - int32_t i; - int32_t j; + int16_t i; + int8_t j; i = -1; j = -1; ft_sort_sprites(cl, -1, -1); - while (++j < cl->mlist.sprite_var) + while (++j < FT_TOTAL_SPRT) { while (++i < cl->mlist.sprite_nbr[j]) { sprite = cl->sprites[cl->mlist.st_o[j]][cl->mlist.sprite_order[ cl->mlist.st_o[j]][i]]; - sprite.current_sprite = (cl->mlist.st_o[j] == 0) ? - 4 : cl->mlist.st_o[j] + 7; + sprite.current_sprite = ft_set_current_sprite(cl, j); 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); |