locked framerate

anyone got any tricks on how to lock the frame rate to
a give rate - say 24fps and if u cant keep to that then
start missing frames.

i dont mind jerky frames- i need the scene to be
updating on time. is it a case of having a Thread that
updates the logic- then another that updates Xith
running best it can?

or is there a better way?

I was thinking of adding frame limiting to my game soon, but I hadn’t gotten around to it yet. I just implemented the GAGE timer, so I was going to work with that to see if I could set it up. I’ll let you know if I get anything working.

Surely someone else must have done this?

Yep… with GAGETimer its particularly easy.

  1. Record the time before you start rendering
  2. Render your frame
  3. call SleepUntil(StartTime + FrameTime)

Where frame time is caculated :

FrameTime = 1.0 / FPS;

Might need to multiply up for milliseconds or something. I always wrap it all up so I deal with seconds.

Kev

Thanks as always Kev. Maybe I’ll add this sooner than I had originally planned while we’re on the topic…

Basically used Kev’s SpaceInvaders example as my bible and went to town. Took maybe 15 minutes and I’m locked at ~33fps right now…

Ant, have a look see at this tutorial by Kev:

http://www.cokeandcode.com/info/tut2d-2.html

runs over to look :slight_smile: click point click