From 0036fe1e23be842e8baa48162bcdb3bf632b02de Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Wed, 18 Mar 2020 18:59:59 +0100 Subject: gng --- src/ft_draw_sprite_extra.c | 12 +++--------- src/ft_draw_traps_extra.c | 3 +-- src/ft_sort_s_t.c | 24 ++++++++++++++++-------- 3 files changed, 20 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index 6096522..9198e8d 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -17,7 +17,7 @@ #include void - ft_sprite_height(t_cub *cl, t_sprite *sprite) + ft_sprite_h_w(t_cub *cl, t_sprite *sprite) { sprite->spriteheight = abs((int)(cl->wlist.y_size / (sprite->transformy))); sprite->drawstarty = -sprite->spriteheight / 2 + cl->wlist.y_size / 2; @@ -26,11 +26,6 @@ void sprite->drawendy = sprite->spriteheight / 2 + cl->wlist.y_size / 2; if (sprite->drawendy >= (int)cl->wlist.y_size) sprite->drawendy = cl->wlist.y_size - 1; -} - -void - ft_sprite_width(t_cub *cl, t_sprite *sprite) -{ sprite->spritewidth = abs((int)(cl->wlist.x_size / (sprite->transformy))); sprite->drawstartx = -sprite->spritewidth / 2 + sprite->spritescreenx; if (sprite->drawstartx < 0) @@ -40,6 +35,7 @@ void sprite->drawendx = cl->wlist.x_size - 1; } + static void ft_init_sprite(t_cub *cl, t_sprite *sprite) { @@ -63,7 +59,6 @@ void i = 0; j = 0; ft_sort_sprites(cl); - ft_sort_s_t(cl, cl->sprites); while (j < cl->mlist.sprite_var) { while (i < cl->mlist.sprite_nbr) @@ -73,8 +68,7 @@ void 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); - ft_sprite_height(cl, &sprite); - ft_sprite_width(cl, &sprite); + ft_sprite_h_w(cl, &sprite); ft_draw_sprite(cl, &sprite); i++; } diff --git a/src/ft_draw_traps_extra.c b/src/ft_draw_traps_extra.c index a2fd0ab..c524190 100644 --- a/src/ft_draw_traps_extra.c +++ b/src/ft_draw_traps_extra.c @@ -36,8 +36,7 @@ void + cl->plist.plane_x * sprite.spritey); sprite.spritescreenx = (int)(cl->wlist.x_size / 2) * (1 + sprite.transformx / sprite.transformy); - ft_sprite_height(cl, &sprite); - ft_sprite_width(cl, &sprite); + ft_sprite_h_w(cl, &sprite); ft_draw_traps(cl, &sprite); i++; } diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c index f91804b..270c974 100644 --- a/src/ft_sort_s_t.c +++ b/src/ft_sort_s_t.c @@ -13,24 +13,32 @@ #include #include #include +#include #include #include void - ft_sort_s_t(cl, t_sprite *s[4096]) + ft_sort_s_t(t_cub *cl, float dist_tab[8][4096]) { uint16_t i; - uint16_t j; - t_sprite tmp_s; + int32_t tmp; + t_sprite *tmp_s; i = 0; - j = 0; - while (i < cl->sprite_var) + tmp_s = ft_calloc(sizeof(t_sprite), 4096); + while (i < cl->mlist.sprite_var) { - if (s[i][0].) - { - + if (dist_tab[i][0] < dist_tab[i + 1][0]) + { + ft_memcpy(tmp_s, cl->sprites[i], 4096); + ft_memcpy(cl->sprites[i], cl->sprites[i + 1], 4096); + ft_memcpy(cl->sprites[i + 1], tmp_s, 4096); + tmp = dist_tab[i][0]; + dist_tab[i][0] = dist_tab[i + 1][0]; + dist_tab[i + 1][0] = tmp; + i = 0; } i++; + printf("qwe%d\n", i); } } -- cgit v1.2.3