From 575990647d8ee677ff9515ecb0c17da9fe66312f Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Mon, 16 Mar 2020 18:57:40 +0100 Subject: fatfingered solution to the sprites problem, changes needed --- Makefile | 2 +- inc/cub3d.h | 1 + map/map_one.cub | 15 ++++-------- src/ft_draw_sprite.c | 60 ++++++++++++++++++++++++++++++---------------- src/ft_draw_sprite_extra.c | 3 ++- 5 files changed, 48 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index dd8d982..c310c87 100644 --- a/Makefile +++ b/Makefile @@ -132,7 +132,7 @@ else CC = gcc endif #--------------------------------------------------------------------------------------------------# -CFLAGS = -std=c89 +CFLAGS = -std=c99 CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -Werror diff --git a/inc/cub3d.h b/inc/cub3d.h index 6c9a010..348d82b 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -78,6 +78,7 @@ int8_t ft_draw_verline(t_cub *cl, int32_t x, int32_t y1, int32_t y2); void ft_sprite_width(t_cub *cl, t_sprite *sprite); void ft_sprite_height(t_cub *cl, t_sprite *sprite); +void ft_sort_sprites(t_cub *cl); void ft_calc_sprite(t_cub *cl); void ft_draw_sprite(t_cub *cl, t_sprite *sprite); void ft_calc_trap(t_cub *cl); diff --git a/map/map_one.cub b/map/map_one.cub index 3dad2cc..3e9886e 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -1,4 +1,4 @@ -R 1400 900 +R 800 800 NO ./media/img/wood_wall_1.xpm SO ./media/img/wood_wall_1.xpm @@ -9,25 +9,20 @@ S ./media/img/pillar.xpm C ./media/img/wood_ceil.xpm F ./media/img/parquet.xpm -S3 ./media/img/pylon.xpm -S4 ./media/img/larry.xpm -S5 ./media/img/wood_chest.xpm - - T ./media/img/spikes.xpm SH 2 111111111111111111 -140000000000300001 -1000E0000000000001 -100100000000300001 +100000000000000001 +100220E02200000001 +100100000000000001 101100000111000001 111111111111110011 1000001 100001 1001001 100001 1011001 100001 111101111111110111 -120500001101010111 +100000001101010111 100000000000000011 100000000000000011 11T000001101000111 diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index 73f277a..ca38fcd 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -13,26 +13,30 @@ #include #include #include +#include #include #include -static void - ft_sort_sprites_norme(float *dist_tab, int32_t it, t_cub *cl) -{ - uint32_t tmp; +/* static void */ +/* ft_sort_sprites_norme(float *dist_tab, int32_t *i, t_cub *cl) */ +/* { */ +/* uint32_t tmp; */ +/* uint32_t it; */ - 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[it]; - cl->mlist.sprite_order[it] = cl->mlist.sprite_order[it + 1]; - cl->mlist.sprite_order[it + 1] = tmp; - it = 0; - } -} +/* it = *i; */ +/* tmp = 0; */ +/* if (dist_tab[it] > dist_tab[it + 1]) */ +/* { */ +/* puts("qwe"); */ +/* tmp = dist_tab[it]; */ +/* dist_tab[it] = dist_tab[it + 1]; */ +/* dist_tab[it + 1] = tmp; */ +/* tmp = cl->mlist.sprite_order[it]; */ +/* cl->mlist.sprite_order[it] = cl->mlist.sprite_order[it + 1]; */ +/* cl->mlist.sprite_order[it + 1] = tmp; */ +/* it = 0; */ +/* } */ +/* } */ void ft_sort_sprites(t_cub *cl) @@ -40,6 +44,7 @@ void float dist_tab[4096]; int32_t it; int32_t jt; + int32_t tmp; it = 0; jt = 0; @@ -47,10 +52,11 @@ void { while (it < cl->mlist.sprite_nbr) { - dist_tab[it] = ((cl->plist.pos_x - cl->sprites[jt][it].s_pos_x) * - (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)); + dist_tab[it] = + ((cl->plist.pos_x - cl->sprites[0][it].s_pos_x) * + (cl->plist.pos_x - cl->sprites[0][it].s_pos_x) + + (cl->plist.pos_y - cl->sprites[0][it].s_pos_y) * + (cl->plist.pos_y - cl->sprites[0][it].s_pos_y)); cl->mlist.sprite_order[it] = it; it++; } @@ -60,8 +66,20 @@ void it = 0; while (it < cl->mlist.sprite_nbr) { - ft_sort_sprites_norme(dist_tab, it, cl); + 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[it]; + cl->mlist.sprite_order[it] = cl->mlist.sprite_order[it + 1]; + cl->mlist.sprite_order[it + 1] = tmp; + it = 0; + } + it++; } + for (int i = 0; i < 4; i++) + printf("%d\n", cl->mlist.sprite_order[i]); } static void diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index 2545ec0..696bdff 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -63,11 +63,12 @@ void i = 0; j = 0; + ft_sort_sprites(cl); while (j < cl->mlist.sprite_var) { while (i < cl->mlist.sprite_nbr) { - sprite = cl->sprites[j][i]; + sprite = cl->sprites[j][cl->mlist.sprite_order[i]]; sprite.current_sprite = (j == 0) ? 4 : 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); -- cgit v1.2.3 From 8ca4c9563629c60122ba998ad64ad2d999d0902a Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Mon, 16 Mar 2020 19:14:11 +0100 Subject: it just works (unpeu) --- inc/cub3d_structs.h | 2 +- map/map_one.cub | 11 ++++-- src/ft_draw_sprite.c | 90 +++++++++++++++++++--------------------------- src/ft_draw_sprite_extra.c | 2 +- 4 files changed, 47 insertions(+), 58 deletions(-) diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index 7545f3b..6db79de 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -197,7 +197,7 @@ typedef struct s_map size_t mapl_len; int32_t sprite_nbr; uint8_t sprite_var; - int32_t sprite_order[4096]; + int32_t sprite_order[8][4096]; int32_t traps_nbr; int32_t traps_order[512]; size_t line_chk; diff --git a/map/map_one.cub b/map/map_one.cub index 3e9886e..244bd53 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -9,20 +9,25 @@ S ./media/img/pillar.xpm C ./media/img/wood_ceil.xpm F ./media/img/parquet.xpm +S3 ./media/img/pylon.xpm +S4 ./media/img/larry.xpm +S5 ./media/img/wood_chest.xpm + + T ./media/img/spikes.xpm SH 2 111111111111111111 -100000000000000001 +140000000000300001 100220E02200000001 -100100000000000001 +100100000000300001 101100000111000001 111111111111110011 1000001 100001 1001001 100001 1011001 100001 111101111111110111 -100000001101010111 +120500001101010111 100000000000000011 100000000000000011 11T000001101000111 diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index ca38fcd..c4e305e 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -17,69 +17,53 @@ #include #include -/* static void */ -/* ft_sort_sprites_norme(float *dist_tab, int32_t *i, t_cub *cl) */ -/* { */ -/* uint32_t tmp; */ -/* uint32_t it; */ +static void + ft_sort_sprites_norme(float *dist_tab, uint16_t *i, uint16_t j, t_cub *cl) +{ + uint32_t tmp; + uint32_t it; -/* it = *i; */ -/* tmp = 0; */ -/* if (dist_tab[it] > dist_tab[it + 1]) */ -/* { */ -/* puts("qwe"); */ -/* tmp = dist_tab[it]; */ -/* dist_tab[it] = dist_tab[it + 1]; */ -/* dist_tab[it + 1] = tmp; */ -/* tmp = cl->mlist.sprite_order[it]; */ -/* cl->mlist.sprite_order[it] = cl->mlist.sprite_order[it + 1]; */ -/* cl->mlist.sprite_order[it + 1] = tmp; */ -/* it = 0; */ -/* } */ -/* } */ + 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; + it = 0; + } +} void ft_sort_sprites(t_cub *cl) { - float dist_tab[4096]; - int32_t it; - int32_t jt; - int32_t tmp; + float dist_tab[8][4096]; + uint16_t it; + uint16_t jt; - it = 0; - jt = 0; - while (jt < cl->mlist.sprite_var) + it = -1; + jt = -1; + while (++jt < cl->mlist.sprite_var) { - while (it < cl->mlist.sprite_nbr) + while (++it < cl->mlist.sprite_nbr) { - dist_tab[it] = - ((cl->plist.pos_x - cl->sprites[0][it].s_pos_x) * - (cl->plist.pos_x - cl->sprites[0][it].s_pos_x) + - (cl->plist.pos_y - cl->sprites[0][it].s_pos_y) * - (cl->plist.pos_y - cl->sprites[0][it].s_pos_y)); - cl->mlist.sprite_order[it] = it; - it++; + dist_tab[jt][it] = + ((cl->plist.pos_x - cl->sprites[jt][it].s_pos_x) * + (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 = 0; - jt++; - } - it = 0; - while (it < cl->mlist.sprite_nbr) - { - 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[it]; - cl->mlist.sprite_order[it] = cl->mlist.sprite_order[it + 1]; - cl->mlist.sprite_order[it + 1] = tmp; - it = 0; - } - it++; + it = -1; } - for (int i = 0; i < 4; i++) - printf("%d\n", cl->mlist.sprite_order[i]); + 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); } static void diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index 696bdff..25c9c7a 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -68,7 +68,7 @@ void { while (i < cl->mlist.sprite_nbr) { - sprite = cl->sprites[j][cl->mlist.sprite_order[i]]; + sprite = cl->sprites[j][cl->mlist.sprite_order[j][i]]; sprite.current_sprite = (j == 0) ? 4 : 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); -- cgit v1.2.3 From 322f3191c5a76cf702d4ddd7b1122219be3f5779 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Mon, 16 Mar 2020 19:24:29 +0100 Subject: fix norme --- src/ft_draw_sprite.c | 8 ++++---- src/ft_draw_sprite_extra.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index c4e305e..1294738 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -23,7 +23,7 @@ static void uint32_t tmp; uint32_t it; - it = *i; + it = *i; tmp = 0; if (dist_tab[it] < dist_tab[it + 1]) { @@ -61,9 +61,9 @@ void } 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); + while (++jt < cl->mlist.sprite_var) + while (++it < cl->mlist.sprite_nbr) + ft_sort_sprites_norme(dist_tab[jt], &it, jt, cl); } static void diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index 25c9c7a..d81913c 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -68,7 +68,7 @@ void { while (i < cl->mlist.sprite_nbr) { - sprite = cl->sprites[j][cl->mlist.sprite_order[j][i]]; + sprite = cl->sprites[j][cl->mlist.sprite_order[j][i]]; sprite.current_sprite = (j == 0) ? 4 : 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); -- cgit v1.2.3 From b4bee5505af7e0cfb3681ed9b866d51bbc3f2690 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Mon, 16 Mar 2020 19:26:15 +0100 Subject: fix norme2 --- src/ft_draw_sprite.c | 8 ++++---- src/ft_draw_sprite_extra.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index 1294738..a196d96 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -18,10 +18,10 @@ #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, uint16_t *i, uint16_t j, t_cub *cl) { uint32_t tmp; - uint32_t it; + uint32_t it; it = *i; tmp = 0; @@ -51,7 +51,7 @@ void while (++it < cl->mlist.sprite_nbr) { dist_tab[jt][it] = - ((cl->plist.pos_x - cl->sprites[jt][it].s_pos_x) * + ((cl->plist.pos_x - cl->sprites[jt][it].s_pos_x) * (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)); @@ -60,7 +60,7 @@ void it = -1; } it = -1; - jt = -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); diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index d81913c..523bf3d 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -63,7 +63,7 @@ void i = 0; j = 0; - ft_sort_sprites(cl); + ft_sort_sprites(cl); while (j < cl->mlist.sprite_var) { while (i < cl->mlist.sprite_nbr) -- cgit v1.2.3 From 0cde149ec5e478c3d6283136065ff0129231c25d Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Mon, 16 Mar 2020 19:43:16 +0100 Subject: bunchoshit --- Makefile | 1 + inc/cub3d.h | 1 + src/ft_draw_sprite_extra.c | 2 +- src/ft_sort_s_t.c | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/ft_sort_s_t.c diff --git a/Makefile b/Makefile index c310c87..09a995d 100644 --- a/Makefile +++ b/Makefile @@ -97,6 +97,7 @@ SRCS_NAME += ft_sfx_trap.c SRCS_NAME += ft_sfx_new_level.c SRCS_NAME += ft_death_screen.c SRCS_NAME += ft_death_hooks.c +SRCS_NAME += ft_sort_s_t.c #--------------------------------------------------------------------------------------------------# SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME}) #--------------------------------------------------------------------------------------------------# diff --git a/inc/cub3d.h b/inc/cub3d.h index 348d82b..4b52aab 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -79,6 +79,7 @@ int8_t ft_draw_verline(t_cub *cl, int32_t x, void ft_sprite_width(t_cub *cl, t_sprite *sprite); void ft_sprite_height(t_cub *cl, t_sprite *sprite); void ft_sort_sprites(t_cub *cl); +void ft_sort_s_t(t_cub *cl, t_sprite *sprites[4096]); void ft_calc_sprite(t_cub *cl); void ft_draw_sprite(t_cub *cl, t_sprite *sprite); void ft_calc_trap(t_cub *cl); diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index 523bf3d..6096522 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -64,6 +63,7 @@ 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) diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c new file mode 100644 index 0000000..f91804b --- /dev/null +++ b/src/ft_sort_s_t.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 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 + +void + ft_sort_s_t(cl, t_sprite *s[4096]) +{ + uint16_t i; + uint16_t j; + t_sprite tmp_s; + + i = 0; + j = 0; + while (i < cl->sprite_var) + { + if (s[i][0].) + { + + } + i++; + } +} -- cgit v1.2.3 From 0036fe1e23be842e8baa48162bcdb3bf632b02de Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Wed, 18 Mar 2020 18:59:59 +0100 Subject: gng --- Makefile | 3 +-- inc/cub3d.h | 4 +--- map/map_one.cub | 6 +++--- src/ft_draw_sprite_extra.c | 12 +++--------- src/ft_draw_traps_extra.c | 3 +-- src/ft_sort_s_t.c | 24 ++++++++++++++++-------- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 09a995d..dd8d982 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,6 @@ SRCS_NAME += ft_sfx_trap.c SRCS_NAME += ft_sfx_new_level.c SRCS_NAME += ft_death_screen.c SRCS_NAME += ft_death_hooks.c -SRCS_NAME += ft_sort_s_t.c #--------------------------------------------------------------------------------------------------# SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME}) #--------------------------------------------------------------------------------------------------# @@ -133,7 +132,7 @@ else CC = gcc endif #--------------------------------------------------------------------------------------------------# -CFLAGS = -std=c99 +CFLAGS = -std=c89 CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -Werror diff --git a/inc/cub3d.h b/inc/cub3d.h index 4b52aab..9c906be 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -76,10 +76,8 @@ void ft_draw_circle(float a, float b, int32_t color, t_cub *cl); int8_t ft_draw_verline(t_cub *cl, int32_t x, int32_t y1, int32_t y2); -void ft_sprite_width(t_cub *cl, t_sprite *sprite); -void ft_sprite_height(t_cub *cl, t_sprite *sprite); +void ft_sprite_h_w(t_cub *cl, t_sprite *sprite); void ft_sort_sprites(t_cub *cl); -void ft_sort_s_t(t_cub *cl, t_sprite *sprites[4096]); void ft_calc_sprite(t_cub *cl); void ft_draw_sprite(t_cub *cl, t_sprite *sprite); void ft_calc_trap(t_cub *cl); diff --git a/map/map_one.cub b/map/map_one.cub index 244bd53..617a5e7 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -18,8 +18,8 @@ T ./media/img/spikes.xpm SH 2 111111111111111111 -140000000000300001 -100220E02200000001 +104000000002340001 +100000E00000000001 100100000000300001 101100000111000001 111111111111110011 @@ -27,7 +27,7 @@ SH 2 1001001 100001 1011001 100001 111101111111110111 -120500001101010111 +100500001101010111 100000000000000011 100000000000000011 11T000001101000111 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 From 967a795b455c97937504c2014184452637c0ec85 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Wed, 18 Mar 2020 19:02:35 +0100 Subject: ? --- src/ft_sort_s_t.c | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 src/ft_sort_s_t.c diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c deleted file mode 100644 index 270c974..0000000 --- a/src/ft_sort_s_t.c +++ /dev/null @@ -1,44 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* 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 - -void - ft_sort_s_t(t_cub *cl, float dist_tab[8][4096]) -{ - uint16_t i; - int32_t tmp; - t_sprite *tmp_s; - - i = 0; - tmp_s = ft_calloc(sizeof(t_sprite), 4096); - while (i < cl->mlist.sprite_var) - { - 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 From 96c7c712f2cffeff9a4bae604715e0edfd6f758e Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Wed, 18 Mar 2020 19:10:35 +0100 Subject: cangelog, norme --- chglog | 9 +++++++++ src/ft_draw_sprite.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 chglog diff --git a/chglog b/chglog new file mode 100644 index 0000000..16d702b --- /dev/null +++ b/chglog @@ -0,0 +1,9 @@ +garder : +modifs a ft_draw_sprites et ft_draw_sprites_extra + +virer : +map + +probleme : + +les sprites differents se chevauchent diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index a196d96..66d69e5 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -40,7 +40,7 @@ static void void ft_sort_sprites(t_cub *cl) { - float dist_tab[8][4096]; + float dist_tab[8][4096]; uint16_t it; uint16_t jt; -- cgit v1.2.3 From 9ef649c14553bd0487ef3ec90fee1b30e24bd627 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Wed, 18 Mar 2020 19:10:45 +0100 Subject: cangelog --- chglog | 4 ++-- map/map_one.cub | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chglog b/chglog index 16d702b..3aad597 100644 --- a/chglog +++ b/chglog @@ -1,9 +1,9 @@ garder : modifs a ft_draw_sprites et ft_draw_sprites_extra +sort sprites ajoutes au header virer : map probleme : - -les sprites differents se chevauchent +les sprites differents se chevauchent, ca va finir par marcher diff --git a/map/map_one.cub b/map/map_one.cub index 617a5e7..e928a6c 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -18,9 +18,9 @@ T ./media/img/spikes.xpm SH 2 111111111111111111 -104000000002340001 +140000000002220001 100000E00000000001 -100100000000300001 +100100000000333001 101100000111000001 111111111111110011 1000001 100001 -- cgit v1.2.3