Timers: method of using them

Started by
2 comments, last by blide 23 years, 9 months ago
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
-blideblide@mail.com
Advertisement
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. =)
Mike BarelaMikeB@yaya.com
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
-blideblide@mail.com
One other question though....I poll the keyboard and mouse for input using direct input....should i use a timer for that? Cause I have noticed that also causes problems on different speed systems...what do u guys do about this?
Thanks in advance!

-blide
blide@mail.com
-blideblide@mail.com

This topic is closed to new replies.

Advertisement