🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Speed control

Started by
3 comments, last by CO 23 years, 11 months ago
Which is the best way to get the same moving speed in every FPS? Chris
Advertisement
use the frame rate to calculate the velocity of your object...
Time wouldn''t be a better solution? I guess it depends on what you want in your game, but I would think time would be a better choice..


hmmm,

bosco()


--
leader of the free world .. or something ..
--leader of the free world .. or something ..
take a look at some of my code
http://members.xoom.com/myBollux/home.html
this updates objects depending on how long the last screen took to draw
Hi Chris,

The best way to control the speed of anything independent of the frame rate is, as bosco said, by updating with respect to time. You could do that one of two ways...

One, you could (as zedzeek does) calculate the time that has elapsed since the last frame was drawn, and determine object positions etc each frame using the interval found. The problem with this is that all these calculations each frame will probably affect your frame rate.

Two, you could recalculate your object positions after a given interval of time (each frame, you''d only check if that time has elapsed). The downside of this is reduced accuracy, but you can usually tweak the length of interval to suit your needs. Note that you should still use the actual amount of time passed once the interval has elapsed, as it may be slightly longer than the nominated interval (and just using the nominal would screw your physics).

Hope that helped

-------------
squirrels are a remarkable source of protein...

This topic is closed to new replies.

Advertisement