diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-18 22:46:00 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-18 22:46:00 +0100 |
commit | fb8ca31ee232fd4db9dd05a088b5fc7b3e83a5a3 (patch) | |
tree | 9b842ddd18c30696af19efffcd2241f02c580c7c /src | |
parent | Bug fix (diff) | |
parent | fatfingers master (diff) | |
download | 42-cub3d-fb8ca31ee232fd4db9dd05a088b5fc7b3e83a5a3.tar.gz 42-cub3d-fb8ca31ee232fd4db9dd05a088b5fc7b3e83a5a3.tar.bz2 42-cub3d-fb8ca31ee232fd4db9dd05a088b5fc7b3e83a5a3.tar.xz 42-cub3d-fb8ca31ee232fd4db9dd05a088b5fc7b3e83a5a3.tar.zst 42-cub3d-fb8ca31ee232fd4db9dd05a088b5fc7b3e83a5a3.zip |
Merge branch 'better_sprites'
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_draw_heals.c | 2 | ||||
-rw-r--r-- | src/ft_draw_sprite.c | 19 | ||||
-rw-r--r-- | src/ft_draw_sprite_extra.c | 4 | ||||
-rw-r--r-- | src/ft_draw_traps.c | 2 | ||||
-rw-r--r-- | src/ft_get_sprite_spawns.c | 4 | ||||
-rw-r--r-- | src/ft_init_map.c | 2 |
6 files changed, 16 insertions, 17 deletions
diff --git a/src/ft_draw_heals.c b/src/ft_draw_heals.c index d51ae97..bc1e1b2 100644 --- a/src/ft_draw_heals.c +++ b/src/ft_draw_heals.c @@ -41,7 +41,7 @@ void int32_t it; it = 0; - while (it < cl->mlist.sprite_nbr) + while (it < cl->mlist.heals_nbr) { dist_tab[it] = ((cl->plist.pos_x - cl->heals[it].s_pos_x) * (cl->plist.pos_x - cl->heals[it].s_pos_x) + diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index ceea280..5fc28d3 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -18,7 +18,7 @@ #include <math.h> 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; - it = 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 (++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) * @@ -62,8 +58,11 @@ void it = -1; jt = -1; while (++jt < cl->mlist.sprite_var) - while (++it < cl->mlist.sprite_nbr) + { + while (++it < cl->mlist.sprite_nbr[jt] - 1) ft_sort_sprites_norme(dist_tab[jt], &it, jt, cl); + it = -1; + } } static void diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index 9198e8d..f4ac6ee 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -58,10 +58,10 @@ void i = 0; j = 0; - ft_sort_sprites(cl); + ft_sort_sprites(cl, -1, -1); while (j < cl->mlist.sprite_var) { - while (i < cl->mlist.sprite_nbr) + while (i < cl->mlist.sprite_nbr[j]) { sprite = cl->sprites[j][cl->mlist.sprite_order[j][i]]; sprite.current_sprite = (j == 0) ? 4 : j + 7; diff --git a/src/ft_draw_traps.c b/src/ft_draw_traps.c index 8bf2221..71e8fe8 100644 --- a/src/ft_draw_traps.c +++ b/src/ft_draw_traps.c @@ -41,7 +41,7 @@ void int32_t it; it = 0; - while (it < cl->mlist.sprite_nbr) + while (it < cl->mlist.traps_nbr) { dist_tab[it] = ((cl->plist.pos_x - cl->traps[it].s_pos_x) * (cl->plist.pos_x - cl->traps[it].s_pos_x) + diff --git a/src/ft_get_sprite_spawns.c b/src/ft_get_sprite_spawns.c index da883b2..d7b6677 100644 --- a/src/ft_get_sprite_spawns.c +++ b/src/ft_get_sprite_spawns.c @@ -29,7 +29,7 @@ void { if (clist->mlist.map[y][x] == c) { - clist->mlist.sprite_nbr++; + clist->mlist.sprite_nbr[s_n]++; clist->sprites[s_n][i].s_pos_x = x; clist->sprites[s_n][i].s_pos_y = y; i++; @@ -60,7 +60,7 @@ void { if (ft_ischarset("2", clist->mlist.map[y][x])) { - clist->mlist.sprite_nbr++; + clist->mlist.sprite_nbr[0]++; clist->sprites[0][i].s_pos_x = x; clist->sprites[0][i].s_pos_y = y; i++; diff --git a/src/ft_init_map.c b/src/ft_init_map.c index d610fac..37fc858 100644 --- a/src/ft_init_map.c +++ b/src/ft_init_map.c @@ -62,6 +62,7 @@ int8_t mlist->nly = 0; mlist->sprite_var = 0; mlist->topsp = 0; + ft_bzero(mlist->sprite_nbr, 4096); ft_bzero(mlist->sprite_order, 4096); ft_bzero(mlist->traps_order, 512); return (0); @@ -90,7 +91,6 @@ int8_t mlist->isskybox = 0; mlist->istraps = 0; mlist->isheals = 0; - mlist->sprite_nbr = 0; mlist->traps_nbr = 0; mlist->heals_nbr = 0; mlist->darklvl = 0; |