maybe resolved wall distorsion

This commit is contained in:
hugogogo
2022-05-03 23:57:19 +02:00
parent 101680c839
commit eb3b5c37a8
6 changed files with 64 additions and 5 deletions

View File

@@ -40,6 +40,17 @@ static void draw_txt_column(t_game *game, t_wall *wall, t_img *txt_img)
int j;
img_x = (wall->posx * txt_img->width) / game->rcast.cell;
// tmp draw map
if (game->ray_activ)
{
printf("img_x:%i ", img_x);
draw_line(&game->img, &wall->vec, 0x00FF00FF);
return ;
}
// tmp end
j = wall->limit;
i = 0;
while (j < wall->height - wall->limit)

View File

@@ -36,16 +36,40 @@ static void calcul_img_column(t_game *game, t_rcast *rcast, t_wall *wall)
if (rcast->is_x == 1)
{
tmp = (rcast->slope_y + wall->delta) / ft_abs(rcast->slope_x);
tmp = wall->delta;
// tmp += rcast->slope_y;
tmp *= -rcast->ray_sign_y;
tmp /= ft_abs(rcast->slope_x);
tmp += game->plr.pos.y;
// tmp draw map
if (game->ray_activ)
printf("tmp:%i ", tmp);
// tmp end
wall->posx = tmp % rcast->cell;
}
else
{
tmp = (rcast->slope_x + wall->delta) / ft_abs(rcast->slope_y);
tmp = wall->delta;
// tmp += rcast->slope_x;
tmp *= -rcast->ray_sign_x;
tmp /= ft_abs(rcast->slope_y);
tmp += game->plr.pos.x;
// tmp draw map
if (game->ray_activ)
printf("tmp:%i ", tmp);
// tmp end
wall->posx = tmp % rcast->cell;
}
// tmp draw map
if (game->ray_activ)
printf("wall->posx:%i ", wall->posx);
// tmp end
}
static void fill_wall_vector(t_rcast *rcast, t_wall *wall)
@@ -93,12 +117,15 @@ void raycast(t_game *game, t_rcast *rcast)
rcast->ray_nb = 0;
while (rcast->ray_nb <= rcast->screen_width)
{
// tmp draw map
// rays
game->ray_activ = 0;
if (rcast->ray_nb == game->ray_highlight)
{
game->ray_activ = 1;
//if (game->ray_activ) printf("hello\n");
game->ray = ray;
}
// tmp end
ray_intersect_wall(game, rcast, &ray);
@@ -116,4 +143,9 @@ void raycast(t_game *game, t_rcast *rcast)
draw_column(game, rcast, &rcast->wall, &game->txt);
(rcast->ray_nb)++;
}
// tmp draw map
printf("\n\n");
// tmp end
}