wip debug ray length
This commit is contained in:
@@ -30,10 +30,14 @@
|
||||
}
|
||||
// tmp end
|
||||
|
||||
static void calcul_wall(t_rcast *rcast)
|
||||
static void wall_length(t_rcast *rcast)
|
||||
{
|
||||
int length;
|
||||
int height;
|
||||
|
||||
// tmp, to draw the map
|
||||
if (rcast->tmp)
|
||||
printf("length:");
|
||||
// tmp end
|
||||
|
||||
rcast->wall.start.x = rcast->ray_nb;
|
||||
rcast->wall.end.x = rcast->ray_nb;
|
||||
@@ -41,16 +45,38 @@ static void calcul_wall(t_rcast *rcast)
|
||||
{
|
||||
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);
|
||||
|
||||
// tmp, to draw the map
|
||||
if (rcast->tmp)
|
||||
printf("(is_x == 1, slope_y != 0)");
|
||||
// tmp end
|
||||
|
||||
}
|
||||
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);
|
||||
|
||||
// tmp, to draw the map
|
||||
if (rcast->tmp)
|
||||
printf("(is_x == 0, slope_x != 0)");
|
||||
// tmp end
|
||||
|
||||
}
|
||||
length = ft_abs(length);
|
||||
height = rcast->wall_height - length;
|
||||
rcast->ray_len = ft_abs(length);
|
||||
|
||||
// tmp, to draw the map
|
||||
if (rcast->tmp)
|
||||
printf(" %i", rcast->ray_len);
|
||||
// tmp end
|
||||
|
||||
}
|
||||
|
||||
static void wall_height(t_rcast *rcast)
|
||||
{
|
||||
int height;
|
||||
|
||||
height = rcast->wall_height - rcast->ray_len;
|
||||
if (height < 0)
|
||||
height = 0;
|
||||
if (height > rcast->screen_height)
|
||||
@@ -98,8 +124,16 @@ void raycast(t_game *game, t_rcast *rcast)
|
||||
draw_line(&game->map_img, &ray, 0x00FF00FF);
|
||||
// tmp end
|
||||
|
||||
calcul_wall(rcast);
|
||||
|
||||
wall_length(rcast);
|
||||
wall_height(rcast);
|
||||
draw_column(game, rcast);
|
||||
(rcast->ray_nb)++;
|
||||
|
||||
// tmp, to draw the map
|
||||
if (rcast->tmp)
|
||||
printf("\n");
|
||||
// tmp end
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user