aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_raycasting.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ft_raycasting.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index 9657b18..3cbd368 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -67,6 +67,19 @@ static void
}
}
+static void
+ ft_castray_norme(uint16_t i, t_win *wl, t_cub *cl)
+{
+ ft_initray(i, cl);
+ cl->rlist.line_h = (int16_t)(wl->y_size / cl->rlist.wall_dist);
+ cl->rlist.wall_t = -cl->rlist.line_h / 2 + wl->y_size / 2;
+ if (cl->rlist.wall_t < 0)
+ cl->rlist.wall_t = 0;
+ cl->rlist.wall_b = cl->rlist.line_h / 2 + wl->y_size / 2;
+ if (cl->rlist.wall_b >= (float)wl->y_size)
+ cl->rlist.wall_b = wl->y_size - 1;
+}
+
void
ft_castray(t_cub *cl)
{
@@ -85,14 +98,7 @@ void
i = 0;
while (i < wl->x_size)
{
- ft_initray(i, cl);
- cl->rlist.line_h = (int16_t)(wl->y_size / cl->rlist.wall_dist);
- cl->rlist.wall_t = -cl->rlist.line_h / 2 + wl->y_size / 2;
- if (cl->rlist.wall_t < 0)
- cl->rlist.wall_t = 0;
- cl->rlist.wall_b = cl->rlist.line_h / 2 + wl->y_size / 2;
- if (cl->rlist.wall_b >= (float)wl->y_size)
- cl->rlist.wall_b = wl->y_size - 1;
+ ft_castray_norme(i, wl, cl);
ft_choose_tex(cl);
ft_calc_tex(cl);
ft_draw_verline(cl, i, cl->rlist.wall_t, cl->rlist.wall_b);