示例#1
0
void		compute_walls(t_image *t)
{
	t_coord	p;
	float	i;
	int		color;

	set_background(t);
	p.angle = ((t->a / 180) * M_PI);
	i = 0;
	while (i <= WIDTH)
	{
		p.x1 = BOX_X;
		p.y1 = ((BOX_Y * ((WIDTH / 2) - i)) / WIDTH);
		p.tmp = p.x1;
		p.x1 = (p.tmp * cos(p.angle)) - (p.y1 * sin(p.angle));
		p.y1 = (p.tmp * sin(p.angle)) + (p.y1 * cos(p.angle));
		p.x1 = p.x1 + t->x;
		p.y1 = p.y1 + t->y;
		t->k = raycast(t, p.x1, p.y1, &color);
		pixel_put_to_image(t, i, color);
		++i;
	}
	mlx_put_image_to_window(t->mlx, t->win, t->imgp, 0, 0);
}
示例#2
0
void		draw(t_tool *t, double x, double y)
{
	t_ray	*ray;
	double	x0;
	double	y0;
	t_color	*final_color;

	final_color = new_color();
	x0 = x;
	while (x0 <= x + 0.5)
	{
		y0 = y;
		while (y0 <= y + 0.5)
		{
			ray = get_ray(t, x0, y0);
			add_color(final_color, draw_suite(ray, t));
			y0 += 0.5;
		}
		x0 += 0.5;
	}
	div_color(final_color, 4);
	normalize_color(final_color);
	pixel_put_to_image(t, x, y, final_color);
}