iPhone game loop

Posts: 18
Joined: 2010.07
Post: #1
I've been trying to game my engine's physics updates seperate from my draw calls using the following method:


But I'm unclear as to how I should actually implement this. Is the actual application 'loop' implemented by the timers created within my GLView? The way I'm understanding this site is that this should all be implemented in the 'game loop', which to me right now is only comprised of the draw call tied to CADisplayLink, but I want the two to be completely separate, correct? Should I be keeping track of when the draws happen, store that time and create a separate timer function that fires off as quick as possible, and within there add the code for determining the animation update? I still have yet to grasp where the actual 'loop' of execution is, so I'm just getting hung up in trying control the flow of execution without going through the draw call.

Thanks in advance for any help.
Quote this message in a reply
Posts: 1,487
Joined: 2002.09
Post: #2
Well, if you are using a timer or a CADisplayLink, then that is what is controlling the body of your loop. You just need to grab the current time at the beginning of each loop to figure out how many fixed steps to perform to catch up and how much interpolation to use (if you are doing that).

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Posts: 3,591
Joined: 2003.06
Post: #3
Exactly. And after you've calculated how many steps you can do, there will be a tiny amount of time left over; that's your interpolation value if you want to use it. You don't have to go to the extra trouble of interpolation unless you want super precise animation. It's a bit of a pain in the rear to implement it but it looks real nice.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Trouble with the canonical game loop TomorrowPlusX 27 20,391 Aug 12, 2009 04:22 AM
Last Post: TomorrowPlusX
  Proper game update loop in Cocoa? LoneIgadzra 13 11,660 May 30, 2008 05:49 AM
Last Post: ThemsAllTook
  Controlling Game Loop Nick 2 4,813 Jul 21, 2007 07:12 PM
Last Post: Nick
  Good Game Loop with Physics Units blobbo 6 7,423 Oct 14, 2005 02:59 AM
Last Post: unknown
  Game Loop in Cocoa robmcq 9 9,914 Sep 27, 2005 10:49 AM
Last Post: akb825