maybe resolved wall distorsion
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -171,6 +171,7 @@ typedef struct s_game
|
|||||||
// rays
|
// rays
|
||||||
int ray_highlight;
|
int ray_highlight;
|
||||||
int ray_activ;
|
int ray_activ;
|
||||||
|
t_vec ray;
|
||||||
// tmp end
|
// tmp end
|
||||||
|
|
||||||
// key hook
|
// key hook
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
NO textures/coin.xpm
|
NO textures/door.xpm
|
||||||
SO textures/chalice.xpm
|
SO textures/chalice.xpm
|
||||||
EA textures/brick.xpm
|
EA textures/brick.xpm
|
||||||
WE textures/wood.xpm
|
WE textures/wood.xpm
|
||||||
|
|||||||
15
maps/map_valid_15.cub
Normal file
15
maps/map_valid_15.cub
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
NO textures/door.xpm
|
||||||
|
SO textures/door.xpm
|
||||||
|
EA textures/door.xpm
|
||||||
|
WE textures/door.xpm
|
||||||
|
|
||||||
|
F 220 , 100, 30
|
||||||
|
|
||||||
|
C 225 , 30 , 0
|
||||||
|
|
||||||
|
1111111111111
|
||||||
|
1000000000001
|
||||||
|
1000000000001
|
||||||
|
10000N0000001
|
||||||
|
1000000000001
|
||||||
|
1111111111111
|
||||||
@@ -40,6 +40,17 @@ static void draw_txt_column(t_game *game, t_wall *wall, t_img *txt_img)
|
|||||||
int j;
|
int j;
|
||||||
|
|
||||||
img_x = (wall->posx * txt_img->width) / game->rcast.cell;
|
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;
|
j = wall->limit;
|
||||||
i = 0;
|
i = 0;
|
||||||
while (j < wall->height - wall->limit)
|
while (j < wall->height - wall->limit)
|
||||||
|
|||||||
@@ -36,16 +36,40 @@ static void calcul_img_column(t_game *game, t_rcast *rcast, t_wall *wall)
|
|||||||
|
|
||||||
if (rcast->is_x == 1)
|
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 += game->plr.pos.y;
|
||||||
|
|
||||||
|
// tmp draw map
|
||||||
|
if (game->ray_activ)
|
||||||
|
printf("tmp:%i ", tmp);
|
||||||
|
// tmp end
|
||||||
|
|
||||||
wall->posx = tmp % rcast->cell;
|
wall->posx = tmp % rcast->cell;
|
||||||
}
|
}
|
||||||
else
|
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 += game->plr.pos.x;
|
||||||
|
|
||||||
|
// tmp draw map
|
||||||
|
if (game->ray_activ)
|
||||||
|
printf("tmp:%i ", tmp);
|
||||||
|
// tmp end
|
||||||
|
|
||||||
wall->posx = tmp % rcast->cell;
|
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)
|
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;
|
rcast->ray_nb = 0;
|
||||||
while (rcast->ray_nb <= rcast->screen_width)
|
while (rcast->ray_nb <= rcast->screen_width)
|
||||||
{
|
{
|
||||||
|
|
||||||
// tmp draw map
|
// tmp draw map
|
||||||
// rays
|
// rays
|
||||||
game->ray_activ = 0;
|
game->ray_activ = 0;
|
||||||
if (rcast->ray_nb == game->ray_highlight)
|
if (rcast->ray_nb == game->ray_highlight)
|
||||||
|
{
|
||||||
game->ray_activ = 1;
|
game->ray_activ = 1;
|
||||||
//if (game->ray_activ) printf("hello\n");
|
game->ray = ray;
|
||||||
|
}
|
||||||
// tmp end
|
// tmp end
|
||||||
|
|
||||||
ray_intersect_wall(game, rcast, &ray);
|
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);
|
draw_column(game, rcast, &rcast->wall, &game->txt);
|
||||||
(rcast->ray_nb)++;
|
(rcast->ray_nb)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tmp draw map
|
||||||
|
printf("\n\n");
|
||||||
|
// tmp end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user