/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_draw_sprite.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/24 20:22:45 by rbousset #+# #+# */ /* Updated: 2020/02/24 20:22:47 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include #include #include #include void ft_draw_sprite(t_cub *cl) { int d; int tex_x; int tex_y; cl->sprites.x = cl->sprites.s_start_x; while (cl->sprites.x < cl->sprites.s_end_x) { tex_x = (int)((cl->sprites.x - (-cl->sprites.s_w / 2 + cl->sprites.s_screen_x)) * cl->tlist[4].img_w / cl->sprites.s_w); cl->sprites.y = cl->sprites.s_start_y; while (cl->sprites.y < cl->sprites.s_end_y) { d = cl->sprites.y * 256 - cl->wlist->y_size * 128 + cl->sprites.s_h * 128; tex_y = ((d * cl->tlist[4].img_h) / cl->sprites.s_h) / 256; if (*(cl->tlist[4].ptr + tex_x + tex_y * cl->tlist[4].sizeline / 4)) { cl->img.ptr[tex_x * 4 + (cl->img.sizeline * tex_y)] = (char)cl->tlist[4].ptr[cl->tlist[4].tex_x * 4 + 4 * cl->tlist[4].img_h * tex_y]; /*puts("qwe");*/ } cl->sprites.y++; } cl->sprites.x++; } }