Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Selecting 2 random objects then making the taller of the 2 spin (http://www.alice.org/community/showthread.php?t=4208)

Us. 04-08-2010 11:23 AM

Selecting 2 random objects then making the taller of the 2 spin
 
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.

bjia56 04-08-2010 11:33 AM

Which part of the project are you having trouble with, the selecting the objects or finding which one is taller?

Us. 04-08-2010 11:38 AM

the user selecting 2 random objects

bjia56 04-08-2010 11: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.

Us. 04-08-2010 11: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

Us. 04-08-2010 11:46 AM

sorry for the misunderstanding

bjia56 04-08-2010 11: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!!! :)


All times are GMT -5. The time now is 08:33 PM.

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