Timers: method of using them
Hi everyone, I have a question about timers. There are basically 2 ways I know off to use timers...one is to determine the fps you want...and in the game loop to check if its time to render. The other method is to render whenever there is a chance and move objects based on how much time has elapsed since last rendering. Both methods make it possible for your game to run on different systems at the same speed. I am wondering what the standard way is for most game developers to use timers in there games. One other thing to mention is that with the first method you could also use a timer of how often to poll the keyboard and mouse to keep that the same on different systems. The second you could also see how much time is passed since last polling and and base how much change on time elapsed. So basically I am looking for the standard on using timers for graphics and input. Thanks for any help!
-blide
blide@mail.com
At work we usually just multiply by the change in time to see how much an object has to move per frame.
position += velocity * dt
where dt is the change in time.
Its easy to implement and it works well. I hope this helped. Good Luck. =)
position += velocity * dt
where dt is the change in time.
Its easy to implement and it works well. I hope this helped. Good Luck. =)
Thanks for the help, I guess that would be the most logical way because on slower systems it will just get jumpier...while on faster systems it will become smoother. So the frame rate will vary based on the system....not be set like the other method i mentioned.
-blide
blide@mail.com
-blide
blide@mail.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement