Setting framerate when using delta timing

BlitzMax Forums/BlitzMax Beginners Area/Setting framerate when using delta timing

QuickSilva(Posted 2009) [#1]
I`m using delta timing for my game and I would like to be able to set my framerate to 30fps. What would be the best way of going about this, apart from using WaitTimer(30)? Is this the best option or are there other methods to achieve better results?

Something else that I would like to be able to do is to have a slow motion mode that I can activate at key points. Is there an easy way to achieve this when using delta timing?

Thanks for any help.

Jason.


ImaginaryHuman(Posted 2009) [#2]
If you're using delta timing then you probably have a fixed framerate and a dynamically adjusting logic update, right? So what is your framerate fixed at? 60fps? If you are using Flip 1 or Flip -1, I guess that's what it'll be. You could do Delay(17) - since at 60fps each frame is 16.6 milliseconds. I'm not that familiar with delta timing so maybe there is another way.


Gabriel(Posted 2009) [#3]
I'm not clear on what you mean by the framerate in this context. It seems at odds with delta timing to try to set a framerate of 30fps. Do you mean the rate at which you draw, the rate at which you update or both? As for better ways and better results, I guess it depends what you're trying to achieve by setting your framerate to 30fps. I don't see an obvious goal in doing it.

As for slow motion, just set your delta time to a quarter of the actual value and everything runs at a quarter of the normal speed.

If you're using delta timing then you probably have a fixed framerate and a dynamically adjusting logic update, right?

Unlikely. If you have a fixed framerate you don't *need* deltatiming, because the delta is, by its very nature, fixed.


MGE(Posted 2009) [#4]
' Top of loop:
t = millisecs() + (1000/30)
' Logic()
' Render()
' Bottom of loop:
Repeat
Until millisecs()>t

Ofcourse you would need to add traps to make sure the millisecs() roll over doesn't occur. ;)


QuickSilva(Posted 2009) [#5]
Well really I just wanted a way to see how the game would run on a slower system by emulating a slower framerate, in this case 30fps instead of 60fps. I guess that I could just set the refresh rate parameter of the graphics command to 30 in order to achieve this.

Jason.


Gabriel(Posted 2009) [#6]
well if you just want to see what happens when things run slower, then ImaginaryHuman's suggestion to just add a delay in should be fine. If you've decoupled rendering and updating then you'll want to try putting a delay in first one, then the other, and then in both, as machine with a decent CPU might still have a rubbish videocard, and vice versa.


xlsior(Posted 2009) [#7]
If you're using delta timing then you probably have a fixed framerate and a dynamically adjusting logic update, right? So what is your framerate fixed at? 60fps? If you are using Flip 1 or Flip -1, I guess that's what it'll be. You could do Delay(17) - since at 60fps each frame is 16.6 milliseconds. I'm not that familiar with delta timing so maybe there is another way.



Doing a 17ms delay pretty much means that you'll be dropping frames all over the place, since you are forcing your program to freeze until almost the same point in the next frame refresh.

You're not just pausing the screen redraws, you're also freezing the logic of your game. Presumable you don't get instant results on the actual code itself, hence you're just adding a massive bottleneck to your program with no real benefit