diff options
Diffstat (limited to 'src/ft_raycasting.c')
-rw-r--r-- | src/ft_raycasting.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index 98f1c81..7ce45d5 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -10,19 +10,23 @@ /* */ /* ************************************************************************** */ +#include <libft.h> #include <cub3d.h> #include <stdint.h> #include <stdio.h> +#include <math.h> void ft_calc_tex(t_cub *clist) { - if (clist->rlist.side == 1) + if (clist->rlist.side == 0) clist->rlist.wall_hit_x = clist->plist->pos_y + clist->rlist.wall_dist * clist->rlist.y_ray_dir; else 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 =(int)(clist->rlist.wall_hit_x * clist->tlist[clist->w_side].img_w);*/ } static void @@ -44,8 +48,10 @@ static void cl->rlist.sqy = (int16_t)cl->rlist.y_ray_pos; ft_detect(cl); if (cl->rlist.side == 0) + { cl->rlist.wall_dist = (cl->rlist.sqx - cl->rlist.x_ray_pos + (1 - cl->mlist->x_step) / 2) / cl->rlist.x_ray_dir; + } else cl->rlist.wall_dist = (cl->rlist.sqy - cl->rlist.y_ray_pos + (1 - cl->mlist->y_step) / 2) / cl->rlist.y_ray_dir; @@ -71,7 +77,6 @@ void cl->rlist.wall_b = wl->y_size - 1; ft_choose_tex(cl); ft_calc_tex(cl); - printf("%f\n", cl->rlist.wall_hit_x); ft_draw_verline(cl, i, cl->rlist.wall_t - 1, cl->rlist.wall_b); i++; } |