Page 1 of 1

game timing

Posted: Fri May 13, 2011 3:46 pm
by slenkar
Hi, I want to run one function at 30 times per second (game logic)
then I want to run another function at 60 times per second ( graphics)

But if the game is running slow, then I want to reduce the number of times graphics are drawn per second, so the logic can stay constant.

I can set up timers and callback functions but cant seem to work out how to do the rest.

Re: game timing

Posted: Fri May 13, 2011 7:39 pm
by lazyprogramer
you can use

Code: Select all

swiWaitForVBlank();
with this code the DS will wait 1 screen update!

Re: game timing

Posted: Mon May 16, 2011 7:00 pm
by zeromus
don't do that. don't draw more graphics than game logic executions. it is silly.

definitely do not use timers for anything like this.

you may want to add a vblank handler to count the number of frames that have elapsed, and then each time you go through your main loop, you can consider whether you are so far behind that you should skip drawing a frame. if so, then just skip it and only run the game logic instead. or, if you are safely caught-up, then do both.