Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // In the class
- bool isRunning;
- sf::Clock simulationTimer;
- const sf::Uint8 simulationRate;
- // The Loop
- sf::Uint32 rate = 0;
- simulationTimer.Reset();
- isRunning = true;
- while ( isRunning )
- {
- // Process to the next scene, if it's different
- // ...
- ScenePtr scene = scenes[ currentScene ];
- // Simulate only simulationRate times a second
- while ( rate > simulationRate )
- {
- // Events, update loop
- sf::Event event;
- while ( window.PollEvent( event ) )
- {
- scene->Update( event );
- }
- scene->Update();
- rate -= ( 1000 / simulationRate );
- }
- // Render as much as possible
- // You could probably put this in the above loop, for battery
- scene->Draw( window );
- // Update the simulation rate...
- rate += simulationTimer.GetElapsedTime();
- simulationTimer.Reset();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement