I am familiar with darkbasic, and they have a Sync command, and sync rate command that can control the frame per second on a game. I am working on a scroller game in blitz3d (using 2d graphics) but it is running way to fast, and short of build some kind of while loop that counts miliseconds, i am trying to determine if there is a global command in blitz that can force a program to execute without going above a particular frame rate.
thanks
- sam
that is using graphics3d
if my game is only using 2d bitmaps/etc the update world etc and those commands would not be used? there stictly 3rd, aren't they?
global timer
const fps = 30; number of frames per second
Repeat
;code goes here
If Millisecs() - Timer > 1000/fps
Timer = millisecs()
Forever
This should work.
This is how I do it.
Graphics 640,480,0,2
SetBuffer BackBuffer()
HidePointer()
FrameRateMax=CreateTimer(30) ;create a timer to cap the FPS
While Not KeyHit(1)
WaitTimer(frameRateMax) ; wait to make sure the framerate does not exceed the max framerate
Rect MouseX(),MouseY(),10,10
Flip
Cls
Wend
End
What you do here is simply set the FrameRateMax timer to the frame rate you want things capped at. This will only cap the speed of a fast system, so a slow system will play slow, but it is a very easy way to lock frame rates.
Oh for god's sake, I'll answer it.
timer = createtimer(30)
while not keydown(1)
;main loop
waittimer timer
wend
end
the timer ticks once every 30th of a second, so the game will not run faster than 30 frames per second, change this value as you see fit, remebering not to set it higher than 60 as this is most people screen refresh rate.
@Andy, the post above you says exactly the same?