Alice Community Random movement of objects in an array/index?

 Random movement of objects in an array/index?
 GameBredDJ Junior Member   Status: Offline Posts: 1 Join Date: May 2012 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.
 x2495iiii Super Moderator     Status: Offline Posts: 3,508 Join Date: Dec 2008 Location: Somewhere in the Continental U.S. 05-25-2012, 12:37 AM Does the movement need to be simultaneous? (')>
 Mr Kidnapper Senior Member   Status: Offline Posts: 442 Join Date: Feb 2011 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.

 Tags array, random

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge