Locking down framerate to 60Hz

Blitz3D Forums/Blitz3D Beginners Area/Locking down framerate to 60Hz

Dax Trajero(Posted 2006) [#1]
I've been looking around at various ways to lock-down framerate to to a solid 60Hz for a *simple arcade game* using a variety of methods:

a) FLIP
b) VWAIT: FLIP FALSE
c) DELTA-TIME & FRAME-LIMITING CODE

I still haven't come across any example when sprites are moving smoothly ALL THE TIME. There always seems to be a moment when the sprites jerk at some point regardless of the methods used. My system is a 1.8GHz CPU with 1GB Ram and a Radeon 9800 Pro on XP SP2 with no other apps running.

Can somewhere tell me this IS avoidable, or is Blitz3D always effected in this way ?

For example, looking at this delta-timing example (below). Initially it looks fine when user switches to Delta Time but I still get the inevitable "glitch" in the movement:
http://home.cmit.net/rwolbeck/programmingtutorial/

Is there better code to avoid these movement "glitches" ?


Dax Trajero(Posted 2006) [#2]
ADDENDUM:
Sorry that link to the delta-time exanple should be:
http://home.cmit.net/rwolbeck/programmingtutorial/reference/framelimiter%20example.htm


lo-tekk(Posted 2006) [#3]
From somewhere deep within this board:

; The variable 'old_time' must be set to the current millisecs time at the start of a new game And when returning from a pause.
milli_secs = MilliSecs ()
the_time_taken = milli_secs - old_time ; Calculate the time the Last loop took to execute.
If the_time_taken > 100 Then the_time_taken = 100 ; This stops disk accesses And the like from causing jumps in position.
game_time = game_time + the_time_taken ; Calculate the value For the 'game_time' variable used with timeouts, etc.
Delta_Time# = the_time_taken * 0.001
;Delta_Time# = the_time_taken / 1000.0 ; Calculate the value for the 'Delta_Time#' variable used to regulate game speed.
old_time = milli_secs ; Update the 'old_time' variable with the current time.


This doesn't lock the framerate, but makes the movement independent from cpu-power.Just multiply all your timebased code with Delta_Time.
Works well for me.


mindstorms(Posted 2006) [#4]
You could simply use a timer set to 60, and then flip false with a waitimer. This is simple, but has problems when out of sinc with moniter refresh rates.


Naughty Alien(Posted 2006) [#5]
here is answers to all of your questions..

http://home.cmit.net/rwolbeck/programmingtutorial/


b32(Posted 2006) [#6]
The glitches are unavoidable I think. I see them too, in 2D and 3D. To minimize them, use fullscreen mode and turn of debugging.