From ef4cc1a996f5a75f89905f18052847bb98ae719c Mon Sep 17 00:00:00 2001 From: hugogogo Date: Mon, 25 Apr 2022 13:17:55 +0200 Subject: [PATCH] visual 3d with buble effect and rays for slope null --- headers/cube3d_macro.h | 2 +- srcs/draw/raycast.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/headers/cube3d_macro.h b/headers/cube3d_macro.h index 477cce1..1e95774 100644 --- a/headers/cube3d_macro.h +++ b/headers/cube3d_macro.h @@ -18,7 +18,7 @@ /* size of a cell on the map */ # define CELL 20 /* height of a wall without perpectiv */ -# define WALL_HEIGHT 300 +# define WALL_HEIGHT 200 /* * keys macro diff --git a/srcs/draw/raycast.c b/srcs/draw/raycast.c index 26b0472..c0d0ea1 100644 --- a/srcs/draw/raycast.c +++ b/srcs/draw/raycast.c @@ -38,9 +38,18 @@ static void calcul_wall(t_rcast *rcast) rcast->wall.start.x = rcast->ray_nb; rcast->wall.end.x = rcast->ray_nb; if (rcast->is_x == 1 && rcast->slope_y != 0) + { length = (rcast->next_x - rcast->ray_step_x) / ft_abs(rcast->slope_y); + length = (double)length * (double)rcast->screen_dist.end.y / (double)rcast->slope_x; +// length = (rcast->next_x - rcast->ray_step_x) / ft_abs(rcast->slope_y); + } if (rcast->is_x == 0 && rcast->slope_x != 0) + { length = (rcast->next_y - rcast->ray_step_y) / ft_abs(rcast->slope_x); + length = (double)length * (double)rcast->screen_dist.end.y / (double)rcast->slope_y; +// length = (rcast->next_y - rcast->ray_step_y) / ft_abs(rcast->slope_x); + } + length = ft_abs(length); height = rcast->wall_height - length; if (height < 0) height = 0;