In this code:
void Game::run()
{
sf::Clock clock;
sf::Time timeSinceLastUpdate = sf::Time::Zero;
while (mWindow.isOpen())
{
processEvents();
timeSinceLastUpdate += clock.restart();
while (timeSinceLastUpdate > TimePerFrame)
{
timeSinceLastUpdate -= TimePerFrame;
processEvents();
update(TimePerFrame);
}
render();
}
}
"TimePerFrame" is a constant that you should set to whatever your game needs, eg if you need a constant framerate of 50 fps, you should set it to 20 (assuming the clock returns values in milliseconds; I think it does, but I'm not very familiar with SFML).
Then, with every iteration of the loop, it looks at how long it's been since the last time the game state was last updated, and if it was longer than 20 ms (or whatever you set for TimePerFrame), it runs the update() function (possibly multiple times, if your render framerate is slower than your game framerate, so it needs to update multiple times per frame).
The update() function is where you do your actual updating of the game state, eg incrementing the position of moving objects, applying health damage, whatever it is you need to happen in your game.
Finally, after all that, render() is where you put your actual rendering (screen drawing) code. A more advanced version of this code (which you should not attempt until you get the basics working) would have render() take timeSinceLastUpdate as an argument, and use it to do interpolation of moving objects (ie, don't draw them where they are, but where they will be timeSinceLastUpdate milliseconds from now; this allows for smoother animation, but since you're only
drawing them in a different position instead of actually
moving them, rounding errors will not accumulate).
One major problem with this code that you need to be aware of is that it will livelock (the technical term for what is referred to in the article as the "spiral of death") if TimePerFrame is less than the time it takes to run the update() function. Don't set TimePerFrame too low!