SFML community forums

Help => General => Topic started by: Dougers on March 17, 2016, 03:23:41 am

Title: Help with delta timer
Post by: Dougers on March 17, 2016, 03:23:41 am
I'm trying to implement delta time into my platformer. I'm pretty new to sfml and would like to try adding this. Each time I try this with various tutorials or explanations, I end up with some sort of error. If I could get some help with this, it would be very helpful. When explaining, it would also help if you could specify where exactly each component should go, (in the while loop for the window, outside main, etc.)
Thanks.
Title: Re: Help with delta timer
Post by: eXpl0it3r on March 17, 2016, 08:25:22 am
Declare an sf::Clock outside of the main loop, reset the clock every main loop iteration, either at the start or the end, when calling restart() on the clock it will return the elapsed time, save that into an sf::Time object and there you got the delta time.

Don't forget to check out the documentation (http://www.sfml-dev.org/documentation/2.3.2/) if you don't understand what a class does or what functions it provides.