Example #1
0
int main(int argc, char** argv) 
{
	// Initiate SFML
	SfmlWindow window;
	GraphicsManager graphicsManager;
	window.initialize(&graphicsManager);
	GameManager gameManager(&window, &graphicsManager);
	gameManager.play();
	return 0;
}
Example #2
0
void CuteChessApplication::newDefaultGame()
{
	// default game is a human versus human game using standard variant and
	// infinite time control
	ChessGame* game = new ChessGame(Chess::BoardFactory::create("standard"),
		new PgnGame());

	game->setTimeControl(TimeControl("inf"));
	game->pause();

	connect(game, SIGNAL(started(ChessGame*)),
		this, SLOT(newGameWindow(ChessGame*)));

	gameManager()->newGame(game,
			       new HumanBuilder(userName()),
			       new HumanBuilder(userName()));
}
Example #3
0
int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdLine, int showCmd)
#endif
{
	sf::RenderWindow window(sf::VideoMode(1440, 900), "Productopolis", sf::Style::Close, sf::ContextSettings(0, 0, 8));
	window.setFramerateLimit(60);
	srand((unsigned)time(0));

	sf::Clock gameClock;
	float dt, dtAccumulator = 0.0f;
	const float timeStep = 1.0f / 60.0f;

	GameManager gameManager(&window);
	gameManager.init();

	sf::Event event;
	while (window.isOpen())
	{
		window.pollEvent(event);
		switch (event.type)
		{
			case sf::Event::Closed: window.close(); break;
			default: gameManager.input(event); break;
		}

		dt = gameClock.restart().asSeconds();
		if (dt > 0.1f) dt = 0.1f;
		dtAccumulator += dt;

		while (dtAccumulator >= timeStep)
		{
			gameManager.update(timeStep, window);
			dtAccumulator -= timeStep;
		}

		window.clear(sf::Color(40, 40, 40));
		gameManager.draw();
		window.display();
	}

	gameManager.deInit();

	return 0;
}