diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2020-02-17 20:25:16 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2020-02-17 20:25:16 +0100 |
commit | 79993a44dcd7a3428a2b09065e33f0fbc6bb69fc (patch) | |
tree | f83eab9ac53c0c5d6feab9f83cf215da95b01adc /src/ft_raycasting.c | |
parent | have correct width and hit zone, supposedly not much left (diff) | |
download | 42-cub3d-79993a44dcd7a3428a2b09065e33f0fbc6bb69fc.tar.gz 42-cub3d-79993a44dcd7a3428a2b09065e33f0fbc6bb69fc.tar.bz2 42-cub3d-79993a44dcd7a3428a2b09065e33f0fbc6bb69fc.tar.xz 42-cub3d-79993a44dcd7a3428a2b09065e33f0fbc6bb69fc.tar.zst 42-cub3d-79993a44dcd7a3428a2b09065e33f0fbc6bb69fc.zip |
some things
Diffstat (limited to '')
-rw-r--r-- | src/ft_raycasting.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index 26a3ec9..6423b9d 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -26,8 +26,18 @@ void clist->rlist.wall_hit_x = clist->plist->pos_x + clist->rlist.wall_dist * clist->rlist.x_ray_dir; clist->rlist.wall_hit_x -= floor(clist->rlist.wall_hit_x); - clist->rlist.tex_x = (clist->rlist.wall_hit_x * (double)clist->tlist[clist->w_side].img_w); - printf("wall_hit_x : %f\ntex_x : %d\nimg_w : %d\n", clist->rlist.wall_hit_x, clist->rlist.tex_x, clist->tlist[clist->w_side].img_w); + clist->rlist.tex_x = (int)(clist->rlist.wall_hit_x * + (double)clist->tlist[clist->w_side].img_w); + if (clist->rlist.side == 0 && clist->rlist.x_ray_dir > 0) + { + clist->rlist.tex_x = clist->tlist[clist->w_side].img_w - clist->rlist.tex_x - 1; + } + if (clist->rlist.side == 1 && clist->rlist.y_ray_dir < 0) + { + clist->rlist.tex_x = clist->tlist[clist->w_side].img_w - clist->rlist.tex_x - 1; + } + printf("tex_x : %d\nwall_hit_x : %f\ntex_x : %d\nimg_w : %d\n", + clist->rlist.wall_hit_x, clist->rlist.tex_x, clist->tlist[clist->w_side].img_w); } static void |