aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsalaaad2 <arthudurant263@gmail.com>2020-02-24 10:20:20 +0100
committersalaaad2 <arthudurant263@gmail.com>2020-02-24 10:20:20 +0100
commit9fc4434c0deac6a3537183266adb9e85f3883db8 (patch)
tree3c4a2e829da3aec0803ff9e8d7f7003ec82f596f /src
parentshpritz (diff)
download42-cub3d-9fc4434c0deac6a3537183266adb9e85f3883db8.tar.gz
42-cub3d-9fc4434c0deac6a3537183266adb9e85f3883db8.tar.bz2
42-cub3d-9fc4434c0deac6a3537183266adb9e85f3883db8.tar.xz
42-cub3d-9fc4434c0deac6a3537183266adb9e85f3883db8.tar.zst
42-cub3d-9fc4434c0deac6a3537183266adb9e85f3883db8.zip
tests
Diffstat (limited to '')
-rw-r--r--src/ft_detect.c3
-rw-r--r--src/ft_draw_sprite.c12
-rw-r--r--src/ft_raycasting.c2
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 <libft.h>
#include <cub3d.h>
#include <stdint.h>
+#include <stdio.h>
#include <stdlib.h>
#include <math.h>
@@ -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++;
}
}