Limit FPS for retro port ...

BlitzMax Forums/BlitzMax Programming/Limit FPS for retro port ...

mic_pringle(Posted 2009) [#1]
Hi,

I am working on an original port (original meaning changing from FPS to 2D top down) of a retro FPS game to BlitzMax.

The games source updates it's logic based on tic's, with there being 35 tic's per second.

I'd like to adhere to this limitation in my port, so how would I best go about limiting the FPS to 35 ?

Thanks

-Mic


matibee(Posted 2009) [#2]
My second example here; http://www.blitzbasic.com/Community/posts.php?topic=86296 limits the fps to 30 :)


mic_pringle(Posted 2009) [#3]
@matibee

Thanks for the response.

I was contemplating using timers, but was wondering, if the actual processing between timer intervals takes longer than the time available until the timer next firers, does the waittimer command then wait until the next timer, therefore potentially halving the framerate ?

Thanks

-Mic


matibee(Posted 2009) [#4]
Ok, well that was the easy way. I think you may be right that missed ticks will be skipped. So keep track of time yourself..



This way it doesn't matter if the processing takes longer than 28ms, it'll do another drawloop straight away.

Of course you could delve into running the logic in a seperate thread but I don't think that will solve the problem on all platforms (once the logic is running slower than 35fps it'll effectively be running in slow motion :/ )


Fry Crayola(Posted 2009) [#5]
I wouldn't keep calling Millisecs(), there's no guarantee the value will be the same each time (although it almost certainly will be, it's best not to rely on it).

Instead, store the value returned by Millisecs() in a variable before entering the loop, and reference that for the rest of the loop.