Alice Community  

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

Reply
 
Thread Tools Display Modes
random objects in an if/else
Old
Porpoise
Guest
 
Status:
Posts: n/a
Smile random objects in an if/else - 04-09-2010, 05:34 AM

I have a question about selecting a random object from a list and using the object selected in an if/else.

More specifically, I am working on a game of wack-a-mole (with hares instead of moles) and I want to make an if/else statement that asks "if the random hare selected is below ground, move the same random object selected up .5 meters. Else, do nothing.

Hopefully the end result will be Alice selecting a hare at random and moving its head above the ground if it it currently below it, and then go back down when you click on it.

Currently, i have it set up so that a specific object chosen by me (hare1, hare2, ect.) goes up the height of its head and gives the player 3 seconds to click it. after the 3 seconds are up, it checks whether it is above or below ground (If the player clicked it, it should be below ground). If it is below ground, it makes the next one go up. If it is above ground (meaning the player hasn't clicked it), it goes down on its own and the next one goes up.

thanks in advance.
Attached Files
File Type: a2w wackamole.a2w (1.44 MB, 16 views)
   
Reply With Quote
Old
bjia56
Guest
 
Status:
Posts: n/a
Default 04-09-2010, 08:51 AM

You could try having a random number command right before your if/else, then use that random number to choose an element from the list.

If this isn't for a school assignment I could possibly make an example for you.

EDIT: Your current world is looking pretty good. As a friendly suggestion, try to have it so that the player cannot click on the hares during the intro.

Last edited by bjia56; 04-09-2010 at 08:54 AM. Reason: Feedback on world
   
Reply With Quote
Old
Porpoise
Guest
 
Status:
Posts: n/a
Default 04-09-2010, 05:14 PM

Thanks so much, after reading your post i thought about it and set variables to random numbers and put all the hares into a list. So when the "hareup" method is called, it calls a random hare from the list.

I also took your advice and made the hares unclickable during the intro.

Again thank you for your help.

Re-uploading in case anyone stumbles on this thread and wants to see my code so they can be inspired on their own projects.
Attached Files
File Type: a2w wackamole.a2w (1.51 MB, 35 views)
   
Reply With Quote
Old
bjia56
Guest
 
Status:
Posts: n/a
Default 04-09-2010, 06:13 PM

No problem, glad to help!
   
Reply With Quote
Reply

Tags
if/else, random, wack-a-mole

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.