How would a game loop work?
scott at tactilemedia.com
Fri Aug 19 00:28:07 CDT 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
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.
He's got some great stuff in there for doing games.
Tactile Media, Multimedia & Design
E: scott at tactilemedia.com
More information about the use-livecode