Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

n0p3x

Frane-Based / Time-based modeling

This topic is 6562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I just rearanged my program so the sprite moves at the same amount of pixels per second no matter how fast/slow the computer is. The only problem is that the frame rate seems very fluctuant. Therefore one minuite the sprite will move nice and smoothly, next it jumps. Is this normal? What''s a good way to get around it? Should I calculate the average frame rate every second rather than that seconds frame rate to keep the figure ''smoother''? Any ideas on this or extra information on the subject of time based modeling would be a great help. Regards, David Stubbs

Share this post


Link to post
Share on other sites
Advertisement
Exactly how are you doing this? I time it with QueryPerformanceCounter() and do like this, every frame:

    Time = Timer.DeltaTime();
Position = Velocity * Time;


Timer.DeltaTime() calculates the time elapsed since the last call to the same function. This is a very simple example, but you get the idea.

-Jussi

Share this post


Link to post
Share on other sites
QueryPerformanceCounter is the most accurate timer there is. On my mainboard (or is it on the processor?), its frequency is over 1MHz, which should be enough for any FPS freak.

Look in your compiler''s help for QueryPerformanceCounter() and QueryPerformanceFrequency(). (Or something like that)

-Jussi

Share this post


Link to post
Share on other sites
The reason you''re having a problem is because GetTickCount()''s timer is only updated when Windows feels like it (ie, has nothing better to do for a time slice). This can result in very inaccurate timing results. It was never intended for high-resolution timing.
As everyone else has already mentioned, QueryPerformanceCounter() is a better way to go. It has much better accuracy.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!