diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-27 15:07:32 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-27 15:07:32 +0100 |
commit | a713e118950f62700a43d21aa33fd2e3d7673af9 (patch) | |
tree | 6ee55630bb28d6626823ad819c62195a9c2bbb5a /src/ft_draw_sprite_extra.c | |
parent | In progress (diff) | |
download | 42-cub3d-a713e118950f62700a43d21aa33fd2e3d7673af9.tar.gz 42-cub3d-a713e118950f62700a43d21aa33fd2e3d7673af9.tar.bz2 42-cub3d-a713e118950f62700a43d21aa33fd2e3d7673af9.tar.xz 42-cub3d-a713e118950f62700a43d21aa33fd2e3d7673af9.tar.zst 42-cub3d-a713e118950f62700a43d21aa33fd2e3d7673af9.zip |
Problem
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); |