diff options
author | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-03-09 19:28:45 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-03-09 19:28:45 +0100 |
commit | 0b14b6447562d2ce7814fc188c988fb1cbf890c2 (patch) | |
tree | e84889ea7edd1b3b4b6b072544e1a0f672a07243 /src/ft_raycasting.c | |
parent | Merge branch 'shpritz' (diff) | |
download | 42-cub3d-0b14b6447562d2ce7814fc188c988fb1cbf890c2.tar.gz 42-cub3d-0b14b6447562d2ce7814fc188c988fb1cbf890c2.tar.bz2 42-cub3d-0b14b6447562d2ce7814fc188c988fb1cbf890c2.tar.xz 42-cub3d-0b14b6447562d2ce7814fc188c988fb1cbf890c2.tar.zst 42-cub3d-0b14b6447562d2ce7814fc188c988fb1cbf890c2.zip |
Norme is pretty bav
Diffstat (limited to '')
-rw-r--r-- | src/ft_raycasting.c | 22 |
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); |