From 8c841c8fcacf3316676daf0aa63ebef408027b70 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Wed, 18 Mar 2020 21:59:03 +0100 Subject: fatfingers 2 --- src/ft_draw_sprite.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/ft_draw_sprite.c') diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index 66d69e5..d0447f6 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -33,7 +33,7 @@ static void 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; + *i = 0; } } @@ -46,9 +46,9 @@ void it = -1; jt = -1; - while (++jt < cl->mlist.sprite_var) + while (++jt <= cl->mlist.sprite_var) { - while (++it < cl->mlist.sprite_nbr) + while (++it <= cl->mlist.sprite_nbr) { dist_tab[jt][it] = ((cl->plist.pos_x - cl->sprites[jt][it].s_pos_x) * @@ -59,11 +59,19 @@ void } 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); + it = 0; + jt = 0; + while (jt < 3) + { + while (it < 6) + { + ft_sort_sprites_norme(dist_tab[jt], &it, jt, cl); + printf("%d\n", jt); + it++; + } + it = 0; + jt++; + } } static void -- cgit v1.2.3 From 768b140f6659e6e110d37a7f8557c3da3669155b Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Wed, 18 Mar 2020 22:35:26 +0100 Subject: fatfingers master --- src/ft_draw_sprite.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'src/ft_draw_sprite.c') diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index d0447f6..cb9a573 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -18,7 +18,7 @@ #include static void - ft_sort_sprites_norme(float *dist_tab, uint16_t *i, uint16_t j, t_cub *cl) + ft_sort_sprites_norme(float *dist_tab, int16_t *i, uint16_t j, t_cub *cl) { uint32_t tmp; uint32_t it; @@ -33,22 +33,18 @@ static void 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; - *i = 0; + *i = -1; } } void - ft_sort_sprites(t_cub *cl) + ft_sort_sprites(t_cub *cl, int16_t it, int16_t jt) { float dist_tab[8][4096]; - uint16_t it; - uint16_t jt; - it = -1; - jt = -1; while (++jt <= cl->mlist.sprite_var) { - while (++it <= cl->mlist.sprite_nbr) + while (++it <= cl->mlist.sprite_nbr[jt]) { dist_tab[jt][it] = ((cl->plist.pos_x - cl->sprites[jt][it].s_pos_x) * @@ -59,19 +55,14 @@ void } it = -1; } - it = 0; - jt = 0; - while (jt < 3) - { - while (it < 6) - { - ft_sort_sprites_norme(dist_tab[jt], &it, jt, cl); - printf("%d\n", jt); - it++; - } - it = 0; - jt++; - } + it = -1; + jt = -1; + while (++jt < cl->mlist.sprite_var) + { + while (++it < cl->mlist.sprite_nbr[jt] - 1) + ft_sort_sprites_norme(dist_tab[jt], &it, jt, cl); + it = -1; + } } static void -- cgit v1.2.3