plr start on middle of a cell, and wall height is well proportionned

This commit is contained in:
hugogogo
2022-04-30 12:09:44 +02:00
parent 58b862ce82
commit 888fa7c116
7 changed files with 26 additions and 111 deletions

View File

@@ -50,25 +50,20 @@ static void wall_length(t_rcast *rcast)
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)
{
double height;
int height;
// height = rcast->screen_height * (rcast->hor - rcast->ray_len) / rcast->hor;
height = rcast->screen_height;
height = rcast->screen_height * rcast->cell;
if (rcast->ray_len)
height /= (double)((double)rcast->ray_len / 100);
height /= rcast->ray_len;
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;
}