wip 3d is sort of working

This commit is contained in:
hugogogo
2022-04-29 21:01:57 +02:00
parent 778ddef393
commit 58b862ce82

View File

@@ -40,43 +40,37 @@ static void wall_length(t_rcast *rcast)
{
len = rcast->next_x - rcast->ray_step_x;
if (rcast->slope_y)
len /= ft_abs(rcast->slope_y);
len = rcast->screen_dist * len / (rcast->slope_x);
len /= rcast->slope_y;
len = rcast->screen_dist * len / rcast->slope_x;
}
else if (rcast->is_x == 0)
{
len = rcast->next_y - rcast->ray_step_y;
if (rcast->slope_x)
len /= ft_abs(rcast->slope_x);
len = rcast->screen_dist * len / (rcast->slope_y);
len /= rcast->slope_x;
len = rcast->screen_dist * len / rcast->slope_y;
}
printf("len:%i\n", len);
rcast->ray_len = ft_abs(len);
}
static void wall_height(t_rcast *rcast)
{
int height;
double height;
/*
height = rcast->screen_height * (rcast->hor - rcast->ray_len) / rcast->hor;
// height = rcast->screen_height * (rcast->hor - rcast->ray_len) / rcast->hor;
height = rcast->screen_height;
if (rcast->ray_len)
height /= (double)((double)rcast->ray_len / 100);
if (height < 0)
height = 0;
if (height > rcast->screen_height)
if (height >= rcast->screen_height)
height = rcast->screen_height;
rcast->wall.start.y = rcast->screen_height / 2 + height / 2;
rcast->wall.end.y = rcast->screen_height / 2 - height / 2;
*/
if (rcast->ray_len)
height = rcast->screen_height / rcast->ray_len;
rcast->wall.start.y = -height / 2 + rcast->screen_height / 2;
if (rcast->wall.start.y < 0)
rcast->wall.start.y = 0;
rcast->wall.end.y = height / 2 + rcast->screen_height / 2;
if (rcast->wall.end.y >= rcast->screen_height)
rcast->wall.end.y = rcast->screen_height;
}
void draw_column(t_game *game, t_rcast *rcast)