Qbasicnews.com

Full Version: Speed consistency
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Alright, I'm using the SDL library, and I have two problems that are related to the program's speed.

The first one, is that when in windowed mode, despite the fact that my program has no set FPS (which I'll get to in the next problem), it runs perfectly fine. But when set to FullScreen mode, it runs well, except for instances on the screen when AlphaBlending is called. This causes the screen to move veeery slowly until the Alpha Blending is gone.

The second one, is that the game doesn't have any set FPS at all, so could someone please explain to me how I could set an FPS variable, and have the program react to it?

Thanks.
You start out with a delay, and increase the delay if the program is running too fast, or decrease it slightly until the program is running at the desired speed. You check the FPS each main game loop, and make the delay react to how many FPS you want.
This does not need adjustment (except for delay variable) and adapts itself to small differences in the frame drawing times.

Code:
const  delay! =1/60   'for 60 fps
t!=timer+delay!
'frames loop
do
'draw your graphics    
  
do :loop until timer>t!:t!=timer+delay!
'end of frames loop
loop

Be warned: SCREENSYNC may interfere with it
Alright, thanks. I haven't gotten it tested on other machines yet, but altering the variable causes it to run at the speed that it was set at, at least as far as I can tell.

But now, the FullScreen mode is all that causes problems.

EDIT: Not... anymore!! HAHAHAHAHAHHAHAHAAAAH!