diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-18 22:40:47 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-18 22:40:47 +0100 |
commit | 3520f4bf3d435991f402e46731c15838baae0894 (patch) | |
tree | c8cbf06ebd69a422cbcf2cb8381916af172da726 /src/ft_draw_sprite.c | |
parent | Still sfx to do (diff) | |
parent | Bug fix (diff) | |
download | 42-cub3d-3520f4bf3d435991f402e46731c15838baae0894.tar.gz 42-cub3d-3520f4bf3d435991f402e46731c15838baae0894.tar.bz2 42-cub3d-3520f4bf3d435991f402e46731c15838baae0894.tar.xz 42-cub3d-3520f4bf3d435991f402e46731c15838baae0894.tar.zst 42-cub3d-3520f4bf3d435991f402e46731c15838baae0894.zip |
Merge branch 'master' into weaps
Diffstat (limited to '')
-rw-r--r-- | src/ft_draw_sprite.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index b304102..ceea280 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -13,23 +13,26 @@ #include <libft.h> #include <cub3d.h> #include <stdint.h> +#include <stdio.h> #include <stdlib.h> #include <math.h> static void - ft_sort_sprites_norme(float *dist_tab, int32_t it, t_cub *cl) + ft_sort_sprites_norme(float *dist_tab, uint16_t *i, uint16_t j, t_cub *cl) { uint32_t tmp; + uint32_t it; + it = *i; tmp = 0; - if (dist_tab[it] > dist_tab[it + 1]) + if (dist_tab[it] < dist_tab[it + 1]) { tmp = dist_tab[it]; dist_tab[it] = dist_tab[it + 1]; dist_tab[it + 1] = tmp; - tmp = cl->mlist.sprite_order[it]; - cl->mlist.sprite_order[it] = cl->mlist.sprite_order[it + 1]; - cl->mlist.sprite_order[it + 1] = tmp; + tmp = cl->mlist.sprite_order[j][it]; + cl->mlist.sprite_order[j][it] = cl->mlist.sprite_order[j][it + 1]; + cl->mlist.sprite_order[j][it + 1] = tmp; it = 0; } } @@ -37,31 +40,30 @@ static void void ft_sort_sprites(t_cub *cl) { - float dist_tab[4096]; - int32_t it; - int32_t jt; + float dist_tab[8][4096]; + uint16_t it; + uint16_t jt; - it = 0; - jt = 0; - while (jt < cl->mlist.sprite_var) + it = -1; + jt = -1; + while (++jt < cl->mlist.sprite_var) { - while (it < cl->mlist.sprite_nbr) + while (++it < cl->mlist.sprite_nbr) { - dist_tab[it] = ((cl->plist.pos_x - cl->sprites[jt][it].s_pos_x) * + dist_tab[jt][it] = + ((cl->plist.pos_x - cl->sprites[jt][it].s_pos_x) * (cl->plist.pos_x - cl->sprites[jt][it].s_pos_x) + (cl->plist.pos_y - cl->sprites[jt][it].s_pos_y) * (cl->plist.pos_y - cl->sprites[jt][it].s_pos_y)); - cl->mlist.sprite_order[it] = it; - it++; + cl->mlist.sprite_order[jt][it] = it; } - it = 0; - jt++; - } - it = 0; - while (it < cl->mlist.sprite_nbr) - { - ft_sort_sprites_norme(dist_tab, it, cl); + it = -1; } + it = -1; + jt = -1; + while (++jt < cl->mlist.sprite_var) + while (++it < cl->mlist.sprite_nbr) + ft_sort_sprites_norme(dist_tab[jt], &it, jt, cl); } static void |