Exemple #1
0
bool App::update()
{
	game_time.update();

	canvas.clear(clan::Colorf(0.0f,0.0f,0.0f, 0.0f));
	rock.set_color(clan::Colorf(1.0f, 1.0f, 1.0f, 0.8f));
	rock.draw(canvas, 0.0f, 0.0f);

	// Rotate tux
	rotation += game_time.get_time_elapsed() * 100.0f;
	clan::Angle angle;
	angle.set_degrees(rotation);
	tux.set_angle(angle);

	// Caculate tux position
	clan::Pointf circle_center(  (float) (canvas.get_width()/2), (float) (canvas.get_height()/2) );
	const float radius = 210.0f;
	int tux_circle = 12;
	tux_position.x = -(radius - tux_radius - tux_circle)  * cos( angle.to_radians() / 2.0f );
	tux_position.y = (radius - tux_radius - tux_circle) * sin( angle.to_radians()/ 2.0f );
	tux_position += circle_center;
	tux_position.x -= tux.get_width()/2;
	tux_position.y -= tux.get_height()/2;

	// Give tux circle blue outer outline, because it looks nice
	canvas.fill_circle(tux_position.x + tux_radius, tux_position.y + tux_radius, tux_radius+tux_circle, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f));

	// Make see through border
	canvas.set_blend_state(blend_state_off);
	canvas.fill_circle(tux_position.x + tux_radius, tux_position.y + tux_radius, tux_radius+tux_circle-2, clan::Colorf(0.0f, 0.0f, 0.0f, 0.0f));
	canvas.reset_blend_state();

	// Give tux circle blue outline, to mask the alpha channel
	canvas.fill_circle(tux_position.x + tux_radius, tux_position.y + tux_radius, tux_radius+2, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f));

	// Draw tux
	tux.draw(canvas, tux_position.x, tux_position.y);

	// Draw text
	font_large.draw_text(canvas, 10-2, 50-2, "ClanLib Layered Window", clan::Colorf(0.1f, 0.1f, 0.1f, 1.0f));
	font_large.draw_text(canvas, 10, 50, "ClanLib Layered Window", clan::Colorf::green);
	font_small.draw_text(canvas, 60-2, 80-2, "Click mouse on the penguin to exit", clan::Colorf(0.1f, 0.1f, 0.1f, 1.0f));
	font_small.draw_text(canvas, 60, 80, "Click mouse on the penguin to exit", clan::Colorf::green);
	font_small.draw_text(canvas, 110-2, 110-2, "Drag rock to move window", clan::Colorf(0.1f, 0.1f, 0.1f, 1.0f));
	font_small.draw_text(canvas, 110, 110, "Drag rock to move window", clan::Colorf::green);

	window.flip(1);

	return !quit;
}
Exemple #2
0
void TuxBall::draw(clan::Canvas &canvas)
{
	sprite.set_scale(scale, scale);
	sprite.set_alpha(0.5f);
	sprite.draw(canvas, xpos, ypos);
}