about fps control
BlitzMax Forums/BlitzMax Beginners Area/about fps control
| ||
i want that my game always works at the same 'speed'. i think have limited the fps to 60 just by using : Graphics 1024,768,32, 60. When i display the fps into my game have 59-60FPS. * Is it a good method or is it better to use Graphics 1024,768,32, 75 and next use an fps limiter code set to 60 fps ? (If this is better where to find an example) (*) note that i've tried to set the graphics parameter to 75, i've 74-75 fps displayed into the game) Thanks for your help ! |
| ||
This isn't a good practice. You should work with FPS independet calculation technics (using the time difference from now and the last calculation) which scale the modification value to the time frame they need to be applied (normally this means * timedifference / 1000.0 on all calculations that need to be frame independet) |
| ||
. |
| ||
thats tweening ... never used it so far ... |
| ||
i'm searching an example, but nothing easy to understand or adapted to bmax for the moment ! |
| ||
There's been loads of discussions and code for this in Bmax. Search for Delta Time |
| ||
ok. note that i already use a lot of 'If MilliSecs() > timer1 + 100' to control frame animation, shoot movement updates... |
| ||
Thats no problem :-) delta time works great with time (or even real event) based updating |
| ||
here a code from Indiepath. Should i now 'paste' my main loop 'inside' the RenderGFX() function ? i'm very bad with fps limitation !!! initial post : http://www.blitzbasic.com/Community/posts.php?topic=49306&hl=delta%20time |
| ||
Finally i've used this from Sushimasta. Perhaps not the best solution, but it's easy to understand and add to my initial program ! Hope this works fine !Strict Global fps:Float = 60 Global time:Float = 1000 / fps Local timer:Float = Millisecs() + time While(Not Keyhit(1)) Local ms:Float = Millisecs() If(ms >= timer) timer = ms + time 'Update() 'Render() Endif |
| ||
Don't limit your update loop like this. Use delta timing. It's easier than you think :) Here's how I calculate smooth rotation and movement in my dungeon app: Local diff:Float = Float(MilliSecs () - old_time) old_time = MilliSecs() Local rot_speed:Float = 0.4 * diff Local move_speed:Float = 0.015 * diff So now I just add rot_speed to rotation if the user wishes to rotate and move_speed to the movement if the user wishes to move forwards or backwards. The trick is you want smooth movement across systems of varying speed, but you want the display to update as much as possible at the same time. |