Hi there, I've got a problem understanding the reason for passing the
TimePerFrame variable to the
update member function of the game class in the following code from chapter 1 of the book:
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) // I understand the fixed time step loop
{
timeSinceLastUpdate -= TimePerFrame;
processEvents();
update(TimePerFrame); //Mistake?? or Really Needed??
}
updateStatistics(elapsedTime);
render();
}
}
Could someone tell me why this is necessary?? It's defined as a constant never changing value. (.01666.....) Why not just define
Game::PlayerSpeed to 1.66666 instead of passing the
TimePerFrame value and then multiplying
Game::PlayerSpeed by
TimePerFrame. Some insight would be greatly appreciated.
Edit:
Sorry forgot Link to full source i'm trying:
https://github.com/SFML/SFML-Game-Development-Book/tree/master/01_Intro/Source