How to perform many actions simultaneously

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
magicscripter
Posts: 2
Joined: Sat Oct 10, 2009 3:58 pm

How to perform many actions simultaneously

Post by magicscripter » Sat Oct 10, 2009 4:25 pm

Hi,
my biggest problem in video game development with Revolution is to perform and synchronize many actions at the same time with the user behaviour.

The Animation Engine enables you to drag and move many controls at the same time, but I'd rather need to roll many sprites simultaneously for character animation.
How do I accomplish this?
I've tried using the 'repeat until' structures, but the script always goes out of control, continuing to perform an action even after the event specified after 'until' (i.e., 'repeat until the mouse is down') has occurred, forcing me to reboot Revolution. I find it is generally always hard to exit a loop in Revolution: I've recently tried even moving an object using the 'mouseMove' handler, and the script didn't stop even when I clicked on a background button containing the 'exit to top' command.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9857
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Post by FourthWorld » Sat Oct 10, 2009 7:16 pm

Most users being much slower than their computer, you can accomplish a surprising variety of things with "send <message> in <time>". What do you want to do?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

magicscripter
Posts: 2
Joined: Sat Oct 10, 2009 3:58 pm

Post by magicscripter » Sat Oct 10, 2009 9:39 pm

I want for instance to show many bitmap animations at the same time also moving simultaneously the groups containing the animation frames or the buttons displaying them as icons; or set up a shoot'em up type game with a gun following the mouse movements until the game is over, and then exit any loop structure opened to accomplish this with no further hassle.
Unfortunately, I notice that once a loop has been opened it's always a problem to close it: even if I code 'repeat until the mouse is down' and click mouse while the action is being executed, or create a button that once clicked does the 'exit to top' statement and click on it, Revolution freezes or keeps doing the specified action forever, until I reboot.
How does the 'send' command work exactly?
Although before moving to Revolution I've had some previous experience with Hypercard and Supercard on the Macs, whose scripting languages also featured this statement, I've never got exactly on the manual what it's meant to.
Could you give me some very concrete examples of what it will enable me to do?
Thank you

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Post by mwieder » Sat Oct 10, 2009 11:34 pm

A couple of things here:

First off, "repeat until the mouse is down with messages" will often be more responsive than just "repeat until the mouse is down" because it give the OS time to breathe and handle other pending events.

Secondly, I often stumble into the rut of trying to handle mouse events within a mouse event handler. That won't work. If, for example, you're coding a mouseUp handler and you put "repeat until the mouse is down" inside it you'll never exit. Instead, one approach is:

Code: Select all

on mouseUp
  send doThings to me in 0 milliseconds
  -- now doThings is outside the mouseUp handler
  -- so there's no conflict.
  -- the mouseUp handler needs to finish before
  -- more mouse events will be processed.
end mouseUp

on doThings
  repeat until the mouse is down
    -- blah
  end repeat
end doThings

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4027
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Post by bn » Sat Oct 10, 2009 11:53 pm

magicscripter,

you might want to look into the user guide pdf page 169 or part 5.9 Timer Based Messaging
then in the Rev Help menu the second item is resource center. Open that. On the left there a tutorial section and in this section is an item applications. There are two scripts "displaying a count down". One blocking and one non-blocking. Have a look at both. They illustrate the difference between a repeat loop (blocking) and a send in time construct (non-blocking)
regards
Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4027
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Post by bn » Sun Oct 11, 2009 12:04 am

@ mark,

btw, I voted for your enhancement request #8305 at the QualityControlCenter, regarding "messages to the future", I liked that one.
regards
Bernd

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: How to perform many actions simultaneously

Post by malte » Sat May 15, 2010 4:25 pm

Hi,

could you clarify what exactly you want to do? animationEngine might be your friend already. :-)

Any moving Object (moved by AEs new movement handlers) receives callback messages that you could hook into to update the icons of a button for example. If you need a specific example, please let me know.

All the best,

Malte

keithb
Posts: 5
Joined: Tue Aug 23, 2011 1:18 am

Re: How to perform many actions simultaneously

Post by keithb » Tue Aug 23, 2011 4:27 am

Well if you want to run parallel processes on your cpu, you have to read how to write code that would make full use of multiple cores. I am not that sure how you would do that, and that is the reason why I intend to practice computer science for 5 years hence. As I think that right about that time, there would be no room for uniform cores.

Post Reply

Return to “Games”