changed all equations of wall height calculation to resolve pixelisation, but dead axis rays re-appeared
This commit is contained in:
@@ -55,7 +55,6 @@ typedef struct s_rcast
|
||||
int ray_step_y;
|
||||
int is_x;
|
||||
int ray_nb;
|
||||
int ray_len;
|
||||
double ratio;
|
||||
} t_rcast;
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ F 220 , 100, 30
|
||||
C 225 , 30 , 0
|
||||
|
||||
1111111111111111111111111111
|
||||
1N00000000000000011100000001
|
||||
1000000000000000011100000001
|
||||
1111000000000000100000110001
|
||||
1111001000000000000110000111
|
||||
1000000000000000010101000001
|
||||
100000000N000000010101000001
|
||||
1111110000000000000000001111
|
||||
1000000000000000000000000001
|
||||
1000000000000000000000000001
|
||||
|
||||
@@ -30,36 +30,23 @@
|
||||
}
|
||||
// tmp end
|
||||
|
||||
static void wall_length(t_rcast *rcast)
|
||||
static void wall_height(t_rcast *rcast)
|
||||
{
|
||||
int len;
|
||||
int height;
|
||||
int delta;
|
||||
|
||||
rcast->wall.start.x = rcast->ray_nb;
|
||||
rcast->wall.end.x = rcast->ray_nb;
|
||||
if (rcast->is_x == 1)
|
||||
{
|
||||
len = rcast->next_x - rcast->ray_step_x;
|
||||
if (rcast->slope_y)
|
||||
len /= rcast->slope_y;
|
||||
len = rcast->screen_dist * len / rcast->slope_x;
|
||||
}
|
||||
delta = rcast->next_x - rcast->ray_step_x;
|
||||
else if (rcast->is_x == 0)
|
||||
{
|
||||
len = rcast->next_y - rcast->ray_step_y;
|
||||
if (rcast->slope_x)
|
||||
len /= rcast->slope_x;
|
||||
len = rcast->screen_dist * len / rcast->slope_y;
|
||||
}
|
||||
rcast->ray_len = ft_abs(len);
|
||||
}
|
||||
|
||||
static void wall_height(t_rcast *rcast)
|
||||
{
|
||||
int height;
|
||||
|
||||
delta = rcast->next_y - rcast->ray_step_y;
|
||||
height = rcast->screen_height * rcast->cell;
|
||||
if (rcast->ray_len)
|
||||
height /= rcast->ray_len;
|
||||
height *= rcast->slope_y * rcast->slope_x;
|
||||
if (delta && rcast->screen_dist)
|
||||
height /= (delta * rcast->screen_dist);
|
||||
|
||||
height = ft_abs(height);
|
||||
if (height < 0)
|
||||
height = 0;
|
||||
if (height > rcast->screen_height)
|
||||
@@ -107,7 +94,6 @@ void raycast(t_game *game, t_rcast *rcast)
|
||||
draw_line(&game->map_img, &ray, 0x00FF00FF);
|
||||
// tmp end
|
||||
|
||||
wall_length(rcast);
|
||||
wall_height(rcast);
|
||||
draw_column(game, rcast);
|
||||
(rcast->ray_nb)++;
|
||||
|
||||
Reference in New Issue
Block a user