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

Author Topic: Help with delta timer  (Read 1078 times)

0 Members and 1 Guest are viewing this topic.

Dougers

  • Newbie
  • *
  • Posts: 1
    • View Profile
Help with delta timer
« 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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Help with delta timer
« Reply #1 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 if you don't understand what a class does or what functions it provides.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/