Skip to content

Instantly share code, notes, and snippets.

@clooth
Created September 23, 2013 11:12
Show Gist options
  • Save clooth/6669120 to your computer and use it in GitHub Desktop.
Save clooth/6669120 to your computer and use it in GitHub Desktop.
void Game::run()
{
sf::Clock clock;
sf::Time timeSinceLastUpdate = sf::Time::Zero;
while (mWindow.isOpen())
{
sf::Time elapsedTime = clock.restart();
timeSinceLastUpdate += elapsedTime;
while (timeSinceLastUpdate > TimePerFrame)
{
timeSinceLastUpdate -= TimePerFrame;
processEvents();
update(TimePerFrame);
}
updateStatistics(elapsedTime);
render();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment