Limiting the FPS?

Blitz3D Forums/Blitz3D Programming/Limiting the FPS?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I have a code that should prevent the game from going too fast, but it's not quite working.. here it is:

SyncRate = 30
while not keydown(1)
 RenderTime = MilliSecs() - RenderStart
 renderStart = MilliSecs()
 If Rendertime<(1000/syncrate) Then temp = (1000/syncrate) - Rendertime: Delay temp
 UpdateWorld
 RenderWorld
 Flip
wend
end


[To sum up the above, it finds out how long it's taking to render one loop, then comparing it to how long it should take, then delaying for the right amount of time]

what's wrong with the above? It DOES limit the fps, but it still allows it to go about 10 fps over the SyncRate value!

how can I make it more percise?