game timing

Post Reply
Posts: 43
Joined: Sun Apr 17, 2011 8:10 pm

game timing

Post by slenkar » Fri May 13, 2011 3:46 pm

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.

Posts: 85
Joined: Mon Sep 27, 2010 5:26 pm

Re: game timing

Post by lazyprogramer » Fri May 13, 2011 7:39 pm

you can use

Code: Select all

with this code the DS will wait 1 screen update!

Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: game timing

Post by zeromus » Mon May 16, 2011 7:00 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests