How to perform many actions simultaneously
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 2
- Joined: Sat Oct 10, 2009 3:58 pm
How to perform many actions simultaneously
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.
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.
-
- VIP Livecode Opensource Backer
- Posts: 9857
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 2
- Joined: Sat Oct 10, 2009 3:58 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
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
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
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:
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
-
- VIP Livecode Opensource Backer
- Posts: 4027
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
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
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
Re: How to perform many actions simultaneously
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
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
Re: How to perform many actions simultaneously
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.