resolve 3d deformation when map too big
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* nbr pixel player move */
|
/* nbr pixel player move */
|
||||||
# define PLR_MV 2
|
# define PLR_MV 5
|
||||||
/* degree of rotation of the player per press */
|
/* degree of rotation of the player per press */
|
||||||
# define PLR_ROT 2
|
# define PLR_ROT 2
|
||||||
/* nbr key you can press at the same time */
|
/* nbr key you can press at the same time */
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
/* screen focal (in degree) */
|
/* screen focal (in degree) */
|
||||||
# define SCREEN_FOCAL 70
|
# define SCREEN_FOCAL 70
|
||||||
/* size of a cell on the map */
|
/* size of a cell on the map */
|
||||||
# define CELL 20
|
# define CELL 40
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* keys macro
|
* keys macro
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ static void fill_wall_vector(t_rcast *rcast, int height)
|
|||||||
|
|
||||||
static void calcul_wall(t_rcast *rcast)
|
static void calcul_wall(t_rcast *rcast)
|
||||||
{
|
{
|
||||||
int height;
|
long int height;
|
||||||
int delta;
|
int delta;
|
||||||
|
|
||||||
rcast->wall.start.x = rcast->ray_nb;
|
rcast->wall.start.x = rcast->ray_nb;
|
||||||
rcast->wall.end.x = rcast->ray_nb;
|
rcast->wall.end.x = rcast->ray_nb;
|
||||||
@@ -51,13 +51,17 @@ static void calcul_wall(t_rcast *rcast)
|
|||||||
delta = rcast->next_x - rcast->ray_step_x;
|
delta = rcast->next_x - rcast->ray_step_x;
|
||||||
else if (rcast->is_x == 0)
|
else if (rcast->is_x == 0)
|
||||||
delta = rcast->next_y - rcast->ray_step_y;
|
delta = rcast->next_y - rcast->ray_step_y;
|
||||||
|
if (rcast->ray_nb % 10) printf("delta:%i ", delta);
|
||||||
height = rcast->screen_height * rcast->cell;
|
height = rcast->screen_height * rcast->cell;
|
||||||
if (rcast->slope_x)
|
if (rcast->slope_x)
|
||||||
height *= rcast->slope_x;
|
height *= rcast->slope_x;
|
||||||
|
if (rcast->ray_nb % 10) printf("height:%li ", height);
|
||||||
if (rcast->slope_y)
|
if (rcast->slope_y)
|
||||||
height *= rcast->slope_y;
|
height *= rcast->slope_y;
|
||||||
|
if (rcast->ray_nb % 10) printf("height:%li ", height);
|
||||||
if (delta && rcast->screen_dist)
|
if (delta && rcast->screen_dist)
|
||||||
height /= (delta * rcast->screen_dist);
|
height /= (delta * rcast->screen_dist);
|
||||||
|
if (rcast->ray_nb % 10) printf("height:%li\n", height);
|
||||||
height = ft_abs(height);
|
height = ft_abs(height);
|
||||||
fill_wall_vector(rcast, height);
|
fill_wall_vector(rcast, height);
|
||||||
}
|
}
|
||||||
@@ -67,6 +71,7 @@ void raycast(t_game *game, t_rcast *rcast)
|
|||||||
t_vec ray;
|
t_vec ray;
|
||||||
|
|
||||||
rcast->ray_nb = 0;
|
rcast->ray_nb = 0;
|
||||||
|
printf("\n");
|
||||||
while (rcast->ray_nb <= rcast->screen_width)
|
while (rcast->ray_nb <= rcast->screen_width)
|
||||||
{
|
{
|
||||||
ray_intersect(game, rcast, &ray);
|
ray_intersect(game, rcast, &ray);
|
||||||
|
|||||||
Reference in New Issue
Block a user