From 79993a44dcd7a3428a2b09065e33f0fbc6bb69fc Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Mon, 17 Feb 2020 20:25:16 +0100 Subject: some things --- map/map_one.cub | 2 +- src/ft_draw_textures.c | 8 ++++---- src/ft_raycasting.c | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/map/map_one.cub b/map/map_one.cub index 00bd7db..9be9d48 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -11,7 +11,7 @@ F 150,150,124 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 -1 0 0 1 0 0 0 0 0 0 0 0 0 0 W 0 0 1 +1 0 0 1 0 0 0 0 0 0 0 0 0 0 N 0 0 1 1 0 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 diff --git a/src/ft_draw_textures.c b/src/ft_draw_textures.c index 5d02036..46e51d7 100644 --- a/src/ft_draw_textures.c +++ b/src/ft_draw_textures.c @@ -24,11 +24,11 @@ void ft_choose_tex(t_cub *clist) { if (clist->rlist.side == 0 && clist->rlist.x_ray_dir < 0) - clist->w_side = 0; - else if (clist->rlist.side == 0 && clist->rlist.x_ray_dir > 0) clist->w_side = 1; + else if (clist->rlist.side == 0 && clist->rlist.x_ray_dir > 0) + clist->w_side = 0; else if (clist->rlist.side == 1 && clist->rlist.y_ray_dir > 0) - clist->w_side = 2; - else clist->w_side = 3; + else + clist->w_side = 2; } 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 -- cgit v1.2.3