Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Random movement of objects in an array/index?
Old
GameBredDJ
Junior Member
 
Status: Offline
Posts: 1
Join Date: May 2012
Default Random movement of objects in an array/index? - 05-24-2012, 10:09 PM

I have a project due pretty soon and needed a bit of advice. I have to make (let's say) 5 object in an array move randomly in different directions on screen. Let's say you have 5 roaches on a page and you want all of them to move in different directions randomly, how would I go about the? I have no problem creating and adding object to an array. My problem is the random movement of each individual objects. Any help or advice would be very appreciated.

Last edited by GameBredDJ; 05-24-2012 at 10:20 PM.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 05-25-2012, 12:37 AM

Does the movement need to be simultaneous?


(')>
   
Reply With Quote
Old
Mr Kidnapper
Senior Member
 
Status: Offline
Posts: 442
Join Date: Feb 2011
Default 05-25-2012, 01:41 AM

Well if you searched the forum and my posts I had actually answered in detail how to do this assignment.

But I'm too lazy to do that myself so I'll keep it simple.
You know how to make a random number right?
All of Alice's units are in percent-decimal so remember to convert it if you use radians or degrees.
For All Together is what you're looking for. It's a loop function for arrays that does it for all items at the same time.
Create random number. It's somewhere in the World's functions. You'll probably be able to figure out what the maximum and minimum number you have to generate is. Keep in mind that if you create this random number in the For All Together, it will be different for each element in the array. If you want it to be the same, then you need to create it outside of the For All Together as a variable.
You can use this same method for turning as well as distance moved.
   
Reply With Quote
Reply

Tags
array, random

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.