aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r5p2.le-101.fr>2020-02-20 04:56:11 +0100
committerRudy Bousset <rbousset@z2r5p2.le-101.fr>2020-02-20 04:56:11 +0100
commitc51b1fb82dbcc90a923375e31a23e963e5161f08 (patch)
tree082f6a470723dc673da3666cce791da67f1df5ac /src
parentNorme (diff)
parentasd works cool (diff)
download42-cub3d-c51b1fb82dbcc90a923375e31a23e963e5161f08.tar.gz
42-cub3d-c51b1fb82dbcc90a923375e31a23e963e5161f08.tar.bz2
42-cub3d-c51b1fb82dbcc90a923375e31a23e963e5161f08.tar.xz
42-cub3d-c51b1fb82dbcc90a923375e31a23e963e5161f08.tar.zst
42-cub3d-c51b1fb82dbcc90a923375e31a23e963e5161f08.zip
Merge branch 'textures_fix'
Diffstat (limited to '')
-rw-r--r--src/ft_get_player_spawn.c2
-rw-r--r--src/ft_init_lists.c2
-rw-r--r--src/ft_raycasting.c6
3 files changed, 7 insertions, 3 deletions
diff --git a/src/ft_get_player_spawn.c b/src/ft_get_player_spawn.c
index f5d2c87..e1f313e 100644
--- a/src/ft_get_player_spawn.c
+++ b/src/ft_get_player_spawn.c
@@ -84,6 +84,8 @@ void
{
plist->pos_x = x + 0.5;
plist->pos_y = y + 0.5;
+ plist->start_x = plist->pos_x;
+ plist->start_y = plist->pos_y;
ft_get_start_side(clist->mlist->map[y][x], clist->plist);
return ;
}
diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c
index b8d7c7c..6917db2 100644
--- a/src/ft_init_lists.c
+++ b/src/ft_init_lists.c
@@ -38,6 +38,8 @@ static t_player
return (NULL);
plist->pos_x = 0;
plist->pos_y = 0;
+ plist->start_x = 0;
+ plist->start_y = 0;
plist->cam_x = 0;
plist->dir_x = -1;
plist->dir_y = 0;
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index 394d6dc..0c00a87 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -19,10 +19,10 @@ void
ft_calc_tex(t_cub *clist)
{
if (clist->rlist.side == 0)
- clist->rlist.wall_hit_x = clist->plist->pos_y +
+ clist->rlist.wall_hit_x = (clist->plist->pos_x - clist->plist->start_x) +
clist->rlist.wall_dist * clist->rlist.y_ray_dir;
else
- clist->rlist.wall_hit_x = clist->plist->pos_x +
+ clist->rlist.wall_hit_x = (clist->plist->pos_y - clist->plist->start_y) +
clist->rlist.wall_dist * clist->rlist.x_ray_dir;
clist->rlist.wall_hit_x -= floor(clist->rlist.wall_hit_x);
clist->tlist[clist->w_side].tex_x = (int)(clist->rlist.wall_hit_x *
@@ -30,7 +30,7 @@ void
if (clist->rlist.side == 0 && clist->rlist.x_ray_dir > 0)
clist->tlist[clist->w_side].tex_x = clist->tlist[clist->w_side].img_w
- clist->tlist[clist->w_side].tex_x - 1;
- if (clist->rlist.side == 1 && clist->rlist.y_ray_dir < 0)
+ else if (clist->rlist.side == 1 && clist->rlist.y_ray_dir < 0)
clist->tlist[clist->w_side].tex_x = clist->tlist[clist->w_side].img_w
- clist->tlist[clist->w_side].tex_x - 1;
}