Example #1
0
bool App::update()
{
	game_time.update();
	
	canvas_center.clear(clan::Colorf(0.0f,0.0f,0.0f, 1.0f));
	rock.draw(canvas_center, 0.0f, 0.0f);

	// Move tux
	for (int cnt=0; cnt<num_tuxballs; cnt++)
	{
		tuxballs[cnt].move(tuxballs, game_time.get_time_elapsed() * 1000.0f);
	}

	// Draw tux
	for (int cnt=0; cnt<num_tuxballs; cnt++)
	{
		tuxballs[cnt].draw(canvas_center);
	}

	std::string fps = clan::string_format("%1 fps", clan::StringHelp::float_to_text(game_time.get_updates_per_second(), 1));
	font.draw_text(canvas_center, 150-2, 150-2, fps, clan::Colorf(0.0f, 0.0f, 0.0f, 1.0f));
	font.draw_text(canvas_center, 150, 150, fps, clan::Colorf(1.0f, 1.0f, 1.0f, 1.0f));

	window_center.flip(0);

	return !quit;
}
Example #2
0
bool GUI::run(clan::GameTime &game_time)
{
	clan::Canvas canvas = app->get_canvas();

	canvas.fill_rect(canvas.get_size(), clan::Gradient(clan::Colorf(0.4f, 0.4f, 0.4f, 1.0f), clan::Colorf(0.0f, 0.0f, 0.0f, 1.0f)));

	gui_direct->gui_manager.render_windows();
	
	std::string fps = clan::string_format("FPS: %1", clan::StringHelp::float_to_text(game_time.get_updates_per_second(), 1));
	fps_font.draw_text(canvas, canvas.get_width() - 100 - 2, 24 - 2, fps, clan::Colorf(0.0f, 0.0f, 0.0f, 1.0f));
	fps_font.draw_text(canvas, canvas.get_width() - 100, 24, fps, clan::Colorf::white);

	fps_font.draw_text(canvas, 24, canvas.get_height() - 48, "Rendering GUI, Directly onto the display window. Some demo windows disabled to improve FPS (in gui_direct.cpp)", clan::Colorf(1.0f, 1.0f, 1.0f, 1.0f));

	balls.Run(canvas, game_time.get_time_elapsed());
	
	clan::KeepAlive::process();
	app->get_window()->flip(0);

	return true;
}