diff --git a/srcs/draw/raycast.c b/srcs/draw/raycast.c index 50ffa74..793a385 100644 --- a/srcs/draw/raycast.c +++ b/srcs/draw/raycast.c @@ -30,7 +30,7 @@ } // tmp end -static void wall_height(t_rcast *rcast) +static void calcul_wall(t_rcast *rcast) { int height; int delta; @@ -42,7 +42,10 @@ static void wall_height(t_rcast *rcast) else if (rcast->is_x == 0) delta = rcast->next_y - rcast->ray_step_y; height = rcast->screen_height * rcast->cell; - height *= rcast->slope_y * rcast->slope_x; + if (rcast->slope_x) + height *= rcast->slope_x; + if (rcast->slope_y) + height *= rcast->slope_y; if (delta && rcast->screen_dist) height /= (delta * rcast->screen_dist); @@ -94,7 +97,7 @@ void raycast(t_game *game, t_rcast *rcast) draw_line(&game->map_img, &ray, 0x00FF00FF); // tmp end - wall_height(rcast); + calcul_wall(rcast); draw_column(game, rcast); (rcast->ray_nb)++; }