diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_draw_sprite.c | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index 41daec4..e41484e 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -16,25 +16,23 @@ #include <stdlib.h> #include <math.h> -/* static void */ -/* ft_sort_sprites_norme(float *dist_tab, int16_t *i, uint16_t j, t_cub *cl) */ -/* { */ -/* uint32_t tmp; */ -/* uint32_t it; */ +static float + **ft_alloc_dist_tab(void) +{ + uint16_t i; + float **dist_tab; -/* it = *i; */ -/* tmp = 0; */ -/* 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[j][it]; */ -/* cl->mlist.sprite_order[j][it] = cl->mlist.sprite_order[j][it + 1]; */ -/* cl->mlist.sprite_order[j][it + 1] = tmp; */ -/* *i = -1; */ -/* } */ -/* } */ + if (!(dist_tab = (float **)ft_calloc((FT_TOTAL_SPRT + 1), sizeof(float*)))) + return (NULL); + i = 0; + while (i < FT_TOTAL_SPRT + 1) + { + if (!(dist_tab[i] = (float *)ft_calloc(4096, sizeof(float)))) + return (NULL); + i++; + } + return (dist_tab); +} void ft_sort_sprites(t_cub *cl, int16_t it, int16_t jt) @@ -56,18 +54,10 @@ void (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[jt][it] = it; */ } it = -1; } } - /* jt = -1; */ - /* while (++jt < FT_TOTAL_SPRT) */ - /* { */ - /* it = -1; */ - /* while (++it < cl->mlist.sprite_nbr[jt] - 1) */ - /* ft_sort_sprites_norme(dist_tab[jt], &it, jt, cl); */ - /* } */ ft_sort_s_t(cl, dist_tab); } |