How would a game loop work?

Geoff Canyon gcanyon at inspiredlogic.com
Sat Aug 20 10:37:12 EDT 2005


On Aug 18, 2005, at 3:19 PM, Ian Leigh wrote:

> What strikes me about rev is that it's harder to manage a flow of  
> things from a main loop. For example, a game might have a  
> particular loop for overall control which steps through all the  
> required stages and then draws a new frame, starting the whole  
> thing off again. How would you best manage a game in rev? Would you  
> have a loop off a 'start game' button which could only be  
> interrupted by the quit action? Just wondering how others have  
> approached laying out games and such programs?

People have already suggested using send..in, which would work for  
this purpose. An alternative is to use wait..with messages. This  
method ends up looking something like this:

on startGame
   doSetup
   repeat
     put milliseconds() into t
     doGameStuff
     if <exit conditions> then exit repeat
     wait (t + 33 - milliseconds()) milliseconds with messages
     -- gives you a max of roughly 30 fps
   end repeat
end startGame



More information about the use-livecode mailing list