From 9fc4434c0deac6a3537183266adb9e85f3883db8 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Mon, 24 Feb 2020 10:20:20 +0100 Subject: tests --- src/ft_detect.c | 3 +-- src/ft_draw_sprite.c | 12 ++++++++---- src/ft_raycasting.c | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ft_detect.c b/src/ft_detect.c index fc49a2d..10d7147 100644 --- a/src/ft_detect.c +++ b/src/ft_detect.c @@ -74,8 +74,7 @@ void cl->rlist.sqy += cl->mlist->y_step; cl->rlist.side = 1; } - if (cl->mlist->map[cl->rlist.sqx][cl->rlist.sqy] == '1' - || cl->mlist->map[cl->rlist.sqx][cl->rlist.sqy] == '2') + if (cl->mlist->map[cl->rlist.sqx][cl->rlist.sqy] == '1') cl->rlist.hit = 1; } } diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index 38c1fd9..e7df49b 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -29,15 +30,18 @@ ft_draw_sprite(t_cub *cl, int x) int d; ver_it = cl->sp_list.s_start_x; - while (ver_it < cl->sp_list.s_end_x) + ver_it = (ver_it < 0) ? -ver_it : ver_it ; + while (ver_it < cl->sp_list.s_end_x - 1) { tex_x = (int)(256 * (ver_it - (-cl->sp_list.s_w / 2 + cl->sp_list.s_screen_x)) * cl->tlist[4].img_w / cl->sp_list.s_w) / 256; hor_it = cl->sp_list.s_start_y; - while (hor_it < cl->sp_list.s_end_y) + while (hor_it < cl->sp_list.s_end_y - 1) { - d = hor_it * 256 - cl->wlist->y_size * 128 + cl->sp_list.s_h * 128; - tex_y = ((d * cl->tlist[4].img_h) / cl->sp_list.s_h) / 256; + d = (hor_it) * 256 - cl->wlist->y_size * 128 + cl->sp_list.s_h * 128; + tex_y = ((d * cl->tlist[4].img_w) / cl->sp_list.s_h) / 256; ft_draw_verline_sprite(cl, x, hor_it, tex_y); + hor_it++; + printf("hor_it : %d ver it : %d", hor_it, ver_it); } ver_it++; } diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index b42e0b7..dd68cd3 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -110,8 +110,8 @@ void ft_choose_tex(cl); ft_calc_tex(cl); ft_calc_sprite(cl); - ft_draw_sprite(cl , i); ft_draw_verline(cl, i, cl->rlist.wall_t, cl->rlist.wall_b); + ft_draw_sprite(cl , i); i++; } } -- cgit v1.2.3