resolve wall distorsion and lag

This commit is contained in:
hugogogo
2022-05-03 18:10:41 +02:00
parent f882f57396
commit 9b28e20199
5 changed files with 28 additions and 28 deletions

View File

@@ -18,12 +18,19 @@ static void calcul_img_column(t_game *game, t_rcast *rcast, t_wall *wall)
}
}
static void fill_wall_vector(t_rcast *rcast, int height)
static void fill_wall_vector(t_rcast *rcast, t_wall *wall)
{
int height;
height = wall->height;
if (height < 0)
height = 0;
wall->limit = 0;
if (height > rcast->screen_height)
{
wall->limit = (height - rcast->screen_height) / 2;
height = rcast->screen_height;
}
rcast->wall.vec.start.y = rcast->screen_height / 2 + height / 2;
rcast->wall.vec.end.y = rcast->screen_height / 2 - height / 2;
}
@@ -46,7 +53,7 @@ static void calcul_wall(t_rcast *rcast)
if (rcast->wall.delta && rcast->screen_dist)
height /= (rcast->wall.delta * rcast->screen_dist);
rcast->wall.height = ft_abs(height);
fill_wall_vector(rcast, rcast->wall.height);
fill_wall_vector(rcast, &rcast->wall);
}
void raycast(t_game *game, t_rcast *rcast)