Alice Community  

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

Reply
 
Thread Tools Display Modes
Selecting 2 random objects then making the taller of the 2 spin
Old
Us.
Guest
 
Status:
Posts: n/a
Default Selecting 2 random objects then making the taller of the 2 spin - 04-08-2010, 10:23 AM

we are to have 5 objects and we need to select 2 of the five at random and make the taller of the 2 spin.
   
Reply With Quote
Old
bjia56
Guest
 
Status:
Posts: n/a
Default 04-08-2010, 10:33 AM

Which part of the project are you having trouble with, the selecting the objects or finding which one is taller?
   
Reply With Quote
Old
Us.
Guest
 
Status:
Posts: n/a
Default 04-08-2010, 10:38 AM

the user selecting 2 random objects
   
Reply With Quote
Old
bjia56
Guest
 
Status:
Posts: n/a
Default 04-08-2010, 10:40 AM

For that all you need to do is have a list of the 5 objects, then use a random integer to choose and store the first object into a variable. Then, you can take that object out of the list and repeat the process.
   
Reply With Quote
Old
Us.
Guest
 
Status:
Posts: n/a
Default 04-08-2010, 10:45 AM

what i ment is i want the user to choose any two specific objects out of the five and the taller of the two should spin
   
Reply With Quote
Old
Us.
Guest
 
Status:
Posts: n/a
Red face 04-08-2010, 10:46 AM

sorry for the misunderstanding
   
Reply With Quote
Old
bjia56
Guest
 
Status:
Posts: n/a
Default 04-08-2010, 10:53 AM

Hmm...that is slightly more difficult...

Try making a list of the objects, then a Boolean (T/F) variable. In the events, have "when the mouse is clicked on (anything)" and keep the anything. In the "do nothing," replace it with "for all in order" and cycle through your list of objects. Do "if object under mouse cursor = item from list", then another if to test whether it is the first object or the second one clicked (change the Boolean after the first click). Then, at the end, store the objects in two separate variables and compare them.

In order to make sure that the user cannot click the same object twice, you might need to use a numerical variable to keep track of which list number you're on, then remove that list element.

Hope that helped!!!
   
Reply With Quote
Reply

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.