/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_basic_keys.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: water_ma +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:43:55 by water_ma #+# #+# */ /* Updated: 2020/02/14 17:43:56 by water_ma ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include /* ** 1 : no ** 0 : so ** 3 : ea ** 4 : we ** 4 : sprite */ void ft_draw_texture(t_cub *cl, int x, int y, int tex_y) { float dist; t_rgb rgb; if ((dist = cl->rlist.wall_dist_tab[x]) <= 0) dist = 0.0001; rgb.r = (uint8_t)cl->tlist[cl->rlist.w_side_tab[x]].ptr[cl->rlist.tex_x_tab[x] * 4 + 4 * cl->tlist[cl->rlist.w_side_tab[x]].img_h * tex_y + 2]; rgb.g = (uint8_t)cl->tlist[cl->rlist.w_side_tab[x]].ptr[cl->rlist.tex_x_tab[x] * 4 + 4 * cl->tlist[cl->rlist.w_side_tab[x]].img_h * tex_y + 1]; rgb.b = (uint8_t)cl->tlist[cl->rlist.w_side_tab[x]].ptr[cl->rlist.tex_x_tab[x] * 4 + 4 * cl->tlist[cl->rlist.w_side_tab[x]].img_h * tex_y]; *(int*)(cl->img.ptr + ((uint16_t)x * 4 + (y * cl->img.sizeline))) = ft_rgb_to_hex(dist, rgb, cl); } void ft_choose_tex(uint16_t x, t_cub *clist) { if (clist->rlist.sqx == clist->mlist.nlx && clist->rlist.sqy == clist->mlist.nly) { clist->w_side = 5; } else { if (clist->rlist.side == 0 && clist->rlist.y_ray_dir < 0) clist->w_side = 1; else if (clist->rlist.side == 0 && clist->rlist.y_ray_dir > 0) clist->w_side = 0; else if (clist->rlist.side == 1 && clist->rlist.x_ray_dir > 0) clist->w_side = 3; else clist->w_side = 2; } clist->rlist.w_side_tab[x] = clist->w_side; }