Jump to content
  • Advertisement


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


Calculating FPS

This topic is 5434 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

I''ve got a Timer class, and it updates each frame. I can also add StartFrame and EndFrame times if neccessary. Whats my calculation to see how many frames per second I''m getting? Also, how do I move my game objects? Is it: Object.x = 4.0f * (EndFrameTime - StartFrameTime); Like, I want the character to move 4 pixels a second. Is that it or am I way off? Thanks =)

Share this post

Link to post
Share on other sites
Depending on what units your timer times in (e.g. milliseconds or seconds) things can vary slightly, but basically here''s an outline.

To see how many fps you are getting:

1 / seconds_taken_to_do_a_frame

e.g. if it takes 0.1 second to do a frame this would be:

1 / 0.1

Which is 10, so 10fps.

That calculation to perform character movement looks about right (I usually store a variable called ''deltatime'' to avoid calculating time differences repeatedly).


Share this post

Link to post
Share on other sites

I didn''t think of this before, but, do you calculate movement based on the speed of the previous frame?


Would you store the EndTime - StartTime from the previous frame, to do the Update objects? Or do you put the Update OBjects _AFTER_ EndTime and use that value?

Share this post

Link to post
Share on other sites
The way I calculate FPS is simple:

Dim FPS_Val as Long
Dim FPS_Count as Long
Dim Last_Second as Long


Render ''All the rendering stuff

FPS_Count = FPS_Count + 1

If GetTickCount >= Last_Second + 1000 Then
FPS_Val = FPS_Count
FPS_Count = 0
Last_Second = GetTickCount
End If


FPS_Val contains the FPS value, updated once per second.

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!