From 14db635d9afa8457e3dbd3563394e5a06f62d962 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Wed, 25 Mar 2020 14:40:34 +0100 Subject: fuck fuck fuck --- src/ft_draw_sprite.c | 5 +++-- src/ft_sort_s_t.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/ft_sort_s_t.c (limited to 'src') diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index b381957..5c0fe41 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -41,9 +41,9 @@ void { float dist_tab[8][4096]; - while (++jt <= cl->mlist.sprite_var) + while (++jt < cl->mlist.sprite_var) { - while (++it <= cl->mlist.sprite_nbr[jt]) + while (++it < cl->mlist.sprite_nbr[jt]) { dist_tab[jt][it] = ((cl->plist.pos_x - cl->sprites[jt][it].s_pos_x) * @@ -62,6 +62,7 @@ void ft_sort_sprites_norme(dist_tab[jt], &it, jt, cl); it = -1; } + ft_sort_s_t(cl, dist_tab); } static void diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c new file mode 100644 index 0000000..f015abc --- /dev/null +++ b/src/ft_sort_s_t.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sort_s_t.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/24 20:22:45 by rbousset #+# #+# */ +/* Updated: 2020/03/09 18:56:01 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include +#include +#include +#include + +/*clearpilled*/ + +void + ft_sort_s_t(t_cub *cl, float dist_tab[8][4096]) +{ + uint16_t i; + int32_t tmp; + + i = 0; + while (i < cl->mlist.sprite_var) + { + if (dist_tab[i][0] < dist_tab[i + 1][0]) + { + i = 0; + } + i++; + } +} -- cgit v1.2.3 From e9458c5d50f43a66d575478a0cbc14d8f6e42baa Mon Sep 17 00:00:00 2001 From: salad Date: Wed, 25 Mar 2020 15:44:53 +0100 Subject: what the fuck les amis --- src/ft_draw_sprite_extra.c | 4 ++-- src/ft_init_map.c | 1 + src/ft_sort_s_t.c | 32 +++++++++++++++++++++++++++----- 3 files changed, 30 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index 323906a..6503980 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -61,8 +61,8 @@ void { 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; + sprite = cl->sprites[cl->mlist.st_o[j]][cl->mlist.sprite_order[cl->mlist.st_o[j]][i]]; + sprite.current_sprite = (cl->mlist.st_o[j] == 0) ? 4 : cl->mlist.st_o[j] + 7; 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); diff --git a/src/ft_init_map.c b/src/ft_init_map.c index 9ddbb47..d252f2e 100644 --- a/src/ft_init_map.c +++ b/src/ft_init_map.c @@ -66,6 +66,7 @@ int8_t mlist->topsp = 0; ft_bzero(mlist->sprite_nbr, 4096); ft_bzero(mlist->sprite_order, 4096); + ft_bzero(mlist->st_o, 4096); ft_bzero(mlist->traps_order, 512); ft_bzero(mlist->heals_order, 64); mlist->weaps_nbr[0] = 0; diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c index f015abc..702d5e6 100644 --- a/src/ft_sort_s_t.c +++ b/src/ft_sort_s_t.c @@ -19,19 +19,41 @@ /*clearpilled*/ +void +ft_init_st(int32_t st_o[8]) +{ + int8_t i; + + i = -1; + while (++i < 3) + st_o[i] = i; +} + void ft_sort_s_t(t_cub *cl, float dist_tab[8][4096]) { - uint16_t i; + int16_t i; int32_t tmp; + float *tmp_i; - i = 0; - while (i < cl->mlist.sprite_var) + i = -1; + ft_init_st(cl->mlist.st_o); + tmp_i = ft_calloc(sizeof(int32_t), 4096); + while (++i < cl->mlist.sprite_var) { if (dist_tab[i][0] < dist_tab[i + 1][0]) { - i = 0; + tmp = cl->mlist.st_o[i]; + cl->mlist.st_o[i] = cl->mlist.st_o[i + 1]; + cl->mlist.st_o[i + 1] = tmp; + ft_memcpy(tmp_i, dist_tab[i], 4096); + ft_memcpy(dist_tab[i], dist_tab[i + 1], 4096); + ft_memcpy(dist_tab[i + 1], tmp_i, 4096); + i = -1; } - i++; } + i = -1; + while (++i < 3) + printf("%d\n", cl->mlist.st_o[i]); + puts("-------------------------"); } -- cgit v1.2.3 From 30d5ae61f527a6cf606e6ca8546311fde678579a Mon Sep 17 00:00:00 2001 From: salad Date: Wed, 25 Mar 2020 16:02:09 +0100 Subject: j'aime trier --- src/ft_sort_s_t.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c index 702d5e6..eaf866e 100644 --- a/src/ft_sort_s_t.c +++ b/src/ft_sort_s_t.c @@ -17,15 +17,15 @@ #include #include -/*clearpilled*/ +/*divine*/ -void -ft_init_st(int32_t st_o[8]) +static void + ft_init_st(uint16_t sprite_var, int32_t st_o[8]) { int8_t i; i = -1; - while (++i < 3) + while (++i < sprite_var) st_o[i] = i; } @@ -37,10 +37,10 @@ void float *tmp_i; i = -1; - ft_init_st(cl->mlist.st_o); - tmp_i = ft_calloc(sizeof(int32_t), 4096); + if (!(tmp_i = ft_calloc(sizeof(int32_t), 4096))) + return ; + ft_init_st(cl->mlist.sprite_var, cl->mlist.st_o); while (++i < cl->mlist.sprite_var) - { if (dist_tab[i][0] < dist_tab[i + 1][0]) { tmp = cl->mlist.st_o[i]; @@ -51,9 +51,4 @@ void ft_memcpy(dist_tab[i + 1], tmp_i, 4096); i = -1; } - } - i = -1; - while (++i < 3) - printf("%d\n", cl->mlist.st_o[i]); - puts("-------------------------"); } -- cgit v1.2.3 From 0734c879193ef0cb9aaf7a8e38c198f6661de192 Mon Sep 17 00:00:00 2001 From: salad Date: Wed, 25 Mar 2020 16:06:10 +0100 Subject: norme, TODO: liks --- src/ft_sort_s_t.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c index eaf866e..c1378c7 100644 --- a/src/ft_sort_s_t.c +++ b/src/ft_sort_s_t.c @@ -13,42 +13,37 @@ #include #include #include -#include -#include -#include - -/*divine*/ static void - ft_init_st(uint16_t sprite_var, int32_t st_o[8]) + ft_init_st(uint16_t sprite_var, int32_t st_o[8]) { - int8_t i; + int8_t i; - i = -1; - while (++i < sprite_var) - st_o[i] = i; + i = -1; + while (++i < sprite_var) + st_o[i] = i; } void - ft_sort_s_t(t_cub *cl, float dist_tab[8][4096]) + ft_sort_s_t(t_cub *cl, float dist_tab[8][4096]) { int16_t i; int32_t tmp; float *tmp_i; i = -1; - if (!(tmp_i = ft_calloc(sizeof(int32_t), 4096))) - return ; - ft_init_st(cl->mlist.sprite_var, cl->mlist.st_o); + if (!(tmp_i = ft_calloc(sizeof(int32_t), 4096))) + return ; + ft_init_st(cl->mlist.sprite_var, cl->mlist.st_o); while (++i < cl->mlist.sprite_var) if (dist_tab[i][0] < dist_tab[i + 1][0]) - { - tmp = cl->mlist.st_o[i]; - cl->mlist.st_o[i] = cl->mlist.st_o[i + 1]; - cl->mlist.st_o[i + 1] = tmp; - ft_memcpy(tmp_i, dist_tab[i], 4096); - ft_memcpy(dist_tab[i], dist_tab[i + 1], 4096); - ft_memcpy(dist_tab[i + 1], tmp_i, 4096); - i = -1; + { + tmp = cl->mlist.st_o[i]; + cl->mlist.st_o[i] = cl->mlist.st_o[i + 1]; + cl->mlist.st_o[i + 1] = tmp; + ft_memcpy(tmp_i, dist_tab[i], 4096); + ft_memcpy(dist_tab[i], dist_tab[i + 1], 4096); + ft_memcpy(dist_tab[i + 1], tmp_i, 4096); + i = -1; } } -- cgit v1.2.3 From fb50b38dbffc812297b1d3980a19ecff070fda4a Mon Sep 17 00:00:00 2001 From: salad Date: Wed, 25 Mar 2020 16:38:34 +0100 Subject: pourquoi se priver de stack --- src/ft_draw_sprite_extra.c | 18 +++++++++--------- src/ft_sort_s_t.c | 4 +--- 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index 6503980..0830d2c 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -54,23 +54,23 @@ void int32_t i; int32_t j; - i = 0; - j = 0; + i = -1; + j = -1; ft_sort_sprites(cl, -1, -1); - while (j < cl->mlist.sprite_var) + while (++j < cl->mlist.sprite_var) { - while (i < cl->mlist.sprite_nbr[j]) + while (++i < cl->mlist.sprite_nbr[j]) { - sprite = cl->sprites[cl->mlist.st_o[j]][cl->mlist.sprite_order[cl->mlist.st_o[j]][i]]; - sprite.current_sprite = (cl->mlist.st_o[j] == 0) ? 4 : cl->mlist.st_o[j] + 7; + sprite = cl->sprites[cl->mlist.st_o[j]][cl->mlist.sprite_order[cl->mlist + .st_o[j]][i]]; + sprite.current_sprite = (cl->mlist.st_o[j] == 0) ? + 4 : cl->mlist.st_o[j] + 7; 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_h_w(cl, &sprite); ft_draw_sprite(cl, &sprite); - i++; } - i = 0; - j++; + i = -1; } } diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c index c1378c7..24ed358 100644 --- a/src/ft_sort_s_t.c +++ b/src/ft_sort_s_t.c @@ -29,11 +29,9 @@ void { int16_t i; int32_t tmp; - float *tmp_i; + float tmp_i[4096]; i = -1; - if (!(tmp_i = ft_calloc(sizeof(int32_t), 4096))) - return ; ft_init_st(cl->mlist.sprite_var, cl->mlist.st_o); while (++i < cl->mlist.sprite_var) if (dist_tab[i][0] < dist_tab[i + 1][0]) -- cgit v1.2.3