Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / how can i limit my fps rate

Author
Message
Teep
21
Years of Service
User Offline
Joined: 30th Nov 2002
Location:
Posted: 6th Dec 2002 09:32
hello!

i've been making my game called Zombie Invasion and just noticed that the fps happens to go pretty high sometimes, so anyone would happen to know how to limit fps ?

thank you
puurunenteemu
Teep
21
Years of Service
User Offline
Joined: 30th Nov 2002
Location:
Posted: 6th Dec 2002 09:36
.....please dont reply, i feel my self as a total idiot.......

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Dec 2002 10:13
Well, if you mean you found the SYNC RATE command, don't feel like an idiot, cos it's not really an ideal method.

For example, say your game was set up to run at 60fps, and it was locked at 60 and everything was fine, until someone with a lower spec PC runs it and their's can't manage 60fps, only 40fps. It'd look jerky and slow.

The best method is to measure the time in miliseconds between syncs, then when you move or the enemy moves, you move depending on how much time has passed, like if 10 miliseconds have passed, move forward 10 units, if 5 miliseconds have passed, move forward 5 units. If you handle all your movement like this and set your SYNC RATE to 0, it'd run at the same virtual speed on every PC regardless of how fast it was - higher spec PC's would be smoother, this is the best way to ensure it can run on low spec machines, and take advantage of high spec machines.


Van-B
hexGEAR
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 6th Dec 2002 11:23
believe it or not, i didn't know about the sync rate command until very recently, in my game, when i look into the world, the fps would drop to 20, and when i look out of the world, it'll shoot up to 50. hmm, i guess i'll use your technique van B, it looks good. but could you drop a formula that i could use to calculate the time in milliseconds?

your birth was a blessing, sent to live and die on earth as a lesson, we each have a star all you have to do is find it, once you do, everyone who sees it will be blinded - DMX
heartbone
21
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 6th Dec 2002 12:10
<update code>
UT= Timer()
<more code>
Rem Time to check position, get Elapsed time.
ET= Timer()- UT


The elapsed time since UT was set in milliseconds is ET.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Dec 2002 12:58
Yep that's along the same idea as mine Heartbone. Say I wanted an object to move 5 world units per second (pseudo code):

UT=TIMER()
Timerate#=0
DO

MOVE OBJECT Timerate#*5.000

SYNC
NT=TIMER()
ET=NT-UT
UT=NT
TimeRate#=ET/1000.000
LOOP

Now Timerate# can be used as the multiplier, just move the object etc by how far you want it to travel per second.


Van-B
Teep
21
Years of Service
User Offline
Joined: 30th Nov 2002
Location:
Posted: 6th Dec 2002 13:37
i didnt actually FIND the sync rate command, i've been programming with db for couple years and this was just a monentary brain disfunction which actually happens to me very often nice piece of code there Van-B

hexGEAR
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 6th Dec 2002 14:40
thanks Van, appreciate it

your birth was a blessing, sent to live and die on earth as a lesson, we each have a star all you have to do is find it, once you do, everyone who sees it will be blinded - DMX
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Dec 2002 15:51
No probs guys.


Van-B

Login to post a reply

Server time is: 2024-04-27 03:47:21
Your offset time is: 2024-04-27 03:47:21