How would a game loop work?

Scott Rossi scott at tactilemedia.com
Fri Aug 19 01:28:07 EDT 2005


Recently, 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?

As Sarah suggested, using the 'send' command would a good way to go.  This
allows you to employ multiple loops, not just a single loop.  Individual
objects can have their own "lives" (looping scripts).

For two very simple examples, execute the following in your message box:

  go url "http://www.tactilemedia.com/tmpanel.rev"

...and see the Bouncer2 and Click Detector demo stacks.

Two things to keep in mind:

1) Be judicious with the frequency of your send messages.  Sending lots of
messages many times per second can eat up processor use and bog down your
game, not to mention your system.

2) If you are moving many objects around a screen at once, avoid locking the
screen.  You can often get away with moving many small objects
simultaneously and get better performance without locking the screen.

Make sure to take a look at Arcade Engine created by Malte brill.
<http://runrev.com/section/revselect/arcadeengine/index.php>

He's got some great stuff in there for doing games.

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com




More information about the use-livecode mailing list