Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - zander24615

Pages: [1]
1
General / Re: SFML Game Book - Delta Time Question?
« on: February 02, 2014, 03:34:39 pm »
ah, thanks. I do suppose that saves time in the long run.

2
General / SFML Game Book - Delta Time Question?
« on: February 02, 2014, 03:17:34 pm »
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

Pages: [1]