Archived

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

Max frame rate. How can i do it?

This topic is 5889 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 am from Brazil, and I am still learning english, so I hope you understand me. I am trying to keep my game running in 60 FPS in every machine. I am programing in VB/DX8. I did something like this: ''Here I measure the frame rate Frames = Frames + 1 If (Timer - UltimoTimer) >= 1# Then mvarFPS = Frames Frames = 0 UltimoTimer = Timer End If '' ''My solution is: if the game reach the max frame rate, ''I keep the game in looping until 1 second finsh. TaxaFPS = 60 If TaxaFPS = Frames And TaxaFPS > 0 Then While (Timer - UltimoTimer) < 1# Wend End If '' ''Timer is a VB´s function. I think is not a good solution. Anyone can help me? Thank you, Euler Almeida

Share this post


Link to post
Share on other sites
You might not want to limit the number of frames it can draw every second. What you might want to do is count how much time has passed and move everything accordingly. So instead of moving a bullet 3 pixels each time move it by a variable that can change depending on the speed of the game. That way everything will move at the same rate no matter what computer it''s on.

I hope that helps.

Share this post


Link to post
Share on other sites
Thank you for your reply.
I thought something like this:
If my space ship move 2 pixels, i would have(x = x + 2*factor)
Factor would be a variable like this:

X = MaxFrameRate/ActualFPS

So,

ActualFPS = 120
MaxFrameRate = 60

then factor = 0,5, and so on.

Bye,

Euler

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You are on the right way.

The problem is to reliably measure the current frametime, you will have to use rdtsc or similar to get accurate results.

Share this post


Link to post
Share on other sites