diff options
Diffstat (limited to 'src/ft_raycasting.c')
-rw-r--r-- | src/ft_raycasting.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index 3cbd368..a0720ea 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -76,8 +76,9 @@ static void 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) + if (cl->rlist.wall_b >= (int16_t)wl->y_size) cl->rlist.wall_b = wl->y_size - 1; + cl->rlist.wall_bz[i] = cl->rlist.wall_b; } void @@ -85,15 +86,13 @@ void { uint16_t i; t_win *wl; - float *dist_tab; wl = &cl->wlist; - i = (wl->y_size / 2) + 1; - while (++i < wl->y_size) - ft_floor_cast(i, cl); - if (!(dist_tab = malloc(sizeof(float) * cl->wlist.x_size))) + if (!(cl->rlist.wall_dist_tab = + (float*)malloc(sizeof(float) * cl->wlist.x_size))) return ; - if (!(cl->rlist.wall_dist_tab = malloc(sizeof(float) * cl->wlist.x_size))) + if (!(cl->rlist.wall_bz = + (int16_t*)malloc(cl->wlist.x_size * sizeof(int16_t)))) return ; i = 0; while (i < wl->x_size) @@ -102,8 +101,12 @@ void ft_choose_tex(cl); ft_calc_tex(cl); ft_draw_verline(cl, i, cl->rlist.wall_t, cl->rlist.wall_b); - dist_tab[i] = cl->rlist.wall_dist; - cl->rlist.wall_dist_tab = dist_tab; + cl->rlist.wall_dist_tab[i] = cl->rlist.wall_dist; i++; } + ft_floor_cast(cl); + ft_calc_sprite(cl); + ft_calc_trap(cl); + ft_memdel((void**)&cl->rlist.wall_dist_tab); + ft_memdel((void**)&cl->rlist.wall_bz); } |