From 02955219fd0a1bd42e3009f77911f5f258d59d34 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Mon, 9 Mar 2020 21:03:16 +0100 Subject: get next sprite --- src/ft_draw_sprite_extra.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'src/ft_draw_sprite_extra.c') diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index 73b8959..f3cdf08 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -45,24 +45,31 @@ void { t_sprite sprite; int32_t i; + int32_t j; i = 0; - while (i < cl->mlist.sprite_nbr) - { - sprite = cl->sprites[i]; - sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5); - sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5); - sprite.invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_y - - cl->plist.dir_x * cl->plist.plane_y); - sprite.transformx = sprite.invdet * (cl->plist.dir_y * sprite.spritex - - cl->plist.dir_x * sprite.spritey); - sprite.transformy = sprite.invdet * (-cl->plist.plane_y * sprite.spritex - + 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_draw_sprite(cl, &sprite); - i++; - } + j = 0; + while (j < cl->mlist.sprite_var) + { + while (i < cl->mlist.sprite_nbr) + { + sprite = cl->sprites[j][i]; + sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5); + sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5); + sprite.invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_y + - cl->plist.dir_x * cl->plist.plane_y); + sprite.transformx = sprite.invdet * (cl->plist.dir_y * sprite.spritex + - cl->plist.dir_x * sprite.spritey); + sprite.transformy = sprite.invdet * (-cl->plist.plane_y * sprite.spritex + + 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_draw_sprite(cl, &sprite); + i++; + } + i = 0; + j++; + } } -- cgit v1.2.3 From b252f8d58790381d5fbece9748e188d42e769aa5 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Tue, 10 Mar 2020 17:46:21 +0100 Subject: 2 sprites max ??? --- src/ft_draw_sprite_extra.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/ft_draw_sprite_extra.c') diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index f3cdf08..45f0dd5 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -49,11 +50,13 @@ void i = 0; j = 0; - while (j < cl->mlist.sprite_var) + while (j < 4) { while (i < cl->mlist.sprite_nbr) { sprite = cl->sprites[j][i]; + sprite.current_sprite = (j == 0) ? 4 : j + 7; + printf("%d\n", j); sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5); sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5); sprite.invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_y -- cgit v1.2.3 From 7d7a0484dbd4b3c65b6c6d37f09337b13d69bc99 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Wed, 11 Mar 2020 18:53:10 +0100 Subject: close but no cigar --- src/ft_draw_sprite_extra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ft_draw_sprite_extra.c') diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index 45f0dd5..f695896 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -50,7 +50,7 @@ void i = 0; j = 0; - while (j < 4) + while (j < 3) { while (i < cl->mlist.sprite_nbr) { -- cgit v1.2.3 From ca5b3689894013365f617cb5513372e6031e8ae7 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Wed, 11 Mar 2020 20:42:12 +0100 Subject: gang_gang --- src/ft_draw_sprite_extra.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src/ft_draw_sprite_extra.c') diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index f695896..c1fa4aa 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -51,28 +51,28 @@ void i = 0; j = 0; while (j < 3) - { - while (i < cl->mlist.sprite_nbr) { - sprite = cl->sprites[j][i]; - sprite.current_sprite = (j == 0) ? 4 : j + 7; - printf("%d\n", j); - sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5); - sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5); - sprite.invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_y - - cl->plist.dir_x * cl->plist.plane_y); - sprite.transformx = sprite.invdet * (cl->plist.dir_y * sprite.spritex - - cl->plist.dir_x * sprite.spritey); - sprite.transformy = sprite.invdet * (-cl->plist.plane_y * sprite.spritex - + 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_draw_sprite(cl, &sprite); - i++; + while (i < cl->mlist.sprite_nbr) + { + sprite = cl->sprites[j][i]; + sprite.current_sprite = (j == 0) ? 4 : j + 7; + /* printf("%d\n", sprite.current_sprite); */ + sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5); + sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5); + sprite.invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_y + - cl->plist.dir_x * cl->plist.plane_y); + sprite.transformx = sprite.invdet * (cl->plist.dir_y * sprite.spritex + - cl->plist.dir_x * sprite.spritey); + sprite.transformy = sprite.invdet * (-cl->plist.plane_y * sprite.spritex + + 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_draw_sprite(cl, &sprite); + i++; + } + i = 0; + j++; } - i = 0; - j++; - } } -- cgit v1.2.3 From 176c86dde0c19ffed0d4845003dbcace3f00b9d2 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Thu, 12 Mar 2020 15:08:06 +0100 Subject: 3 sprites but gns needs work :^) --- src/ft_draw_sprite_extra.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/ft_draw_sprite_extra.c') diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index c1fa4aa..0f923e7 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -50,13 +50,19 @@ void i = 0; j = 0; - while (j < 3) + printf("%d\n", cl->sprites[0][0].s_pos_x); + printf("%d\n", cl->sprites[1][0].s_pos_x); + printf("%d\n", cl->sprites[2][0].s_pos_x); + /* printf("%d\n", cl->sprites[3][0].s_pos_x); */ + /* cl->sprites[2][0].s_pos_x = 4; */ + /* cl->sprites[2][0].s_pos_y = 2; */ + while (j <= cl->mlist.sprite_var) { while (i < cl->mlist.sprite_nbr) { sprite = cl->sprites[j][i]; sprite.current_sprite = (j == 0) ? 4 : j + 7; - /* printf("%d\n", sprite.current_sprite); */ + /* printf("j :%d curr : %d\n", j, sprite.current_sprite); */ sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5); sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5); sprite.invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_y -- cgit v1.2.3 From 71d55e5448007f90239a65279d8dbb07ee7b092a Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Thu, 12 Mar 2020 16:26:46 +0100 Subject: NORMED AND FIXED .......!!! --- src/ft_draw_sprite_extra.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'src/ft_draw_sprite_extra.c') diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index 0f923e7..f6a148c 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -41,6 +41,19 @@ void sprite->drawendx = cl->wlist.x_size - 1; } +static void + ft_init_sprite(t_cub *cl, t_sprite *sprite) +{ + sprite->invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_y + - cl->plist.dir_x * cl->plist.plane_y); + sprite->transformx = sprite->invdet * (cl->plist.dir_y * sprite->spritex + - cl->plist.dir_x * sprite->spritey); + sprite->transformy = sprite->invdet * (-cl->plist.plane_y * sprite->spritex + + cl->plist.plane_x * sprite->spritey); + sprite->spritescreenx = (int)(cl->wlist.x_size / 2) * + (1 + sprite->transformx / sprite->transformy); +} + void ft_calc_sprite(t_cub *cl) { @@ -50,29 +63,15 @@ void i = 0; j = 0; - printf("%d\n", cl->sprites[0][0].s_pos_x); - printf("%d\n", cl->sprites[1][0].s_pos_x); - printf("%d\n", cl->sprites[2][0].s_pos_x); - /* printf("%d\n", cl->sprites[3][0].s_pos_x); */ - /* cl->sprites[2][0].s_pos_x = 4; */ - /* cl->sprites[2][0].s_pos_y = 2; */ - while (j <= cl->mlist.sprite_var) + while (j < cl->mlist.sprite_var - 1) { while (i < cl->mlist.sprite_nbr) { sprite = cl->sprites[j][i]; sprite.current_sprite = (j == 0) ? 4 : j + 7; - /* printf("j :%d curr : %d\n", j, sprite.current_sprite); */ sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5); sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5); - sprite.invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_y - - cl->plist.dir_x * cl->plist.plane_y); - sprite.transformx = sprite.invdet * (cl->plist.dir_y * sprite.spritex - - cl->plist.dir_x * sprite.spritey); - sprite.transformy = sprite.invdet * (-cl->plist.plane_y * sprite.spritex - + cl->plist.plane_x * sprite.spritey); - sprite.spritescreenx = (int)(cl->wlist.x_size / 2) * - (1 + sprite.transformx / sprite.transformy); + ft_init_sprite(cl, &sprite); ft_sprite_height(cl, &sprite); ft_sprite_width(cl, &sprite); ft_draw_sprite(cl, &sprite); -- cgit v1.2.3