Alice Community  

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

Reply
 
Thread Tools Display Modes
Old
OwningDTW
Guest
 
Status:
Posts: n/a
Default 08-06-2010, 05:27 PM

Quote:
Originally Posted by georgie7896 View Post
I am having a similar issue I have my random part OK but I can not figure out how you click on a bug and make it disappear. Anyone able to help? Here is what I have so far. I tried to click on create new method and while it was open click on properties but the program would not allow me to do so.

Please help

Thanks Ginger
Can anyone lend a helping hand here in terms of the random movements?
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 08-06-2010, 05:33 PM

Well if you want a person to randomly turn a certain degree, just make an if/else statement in the part where you want them to move (you can make it in an infinite loop if you want them to always move randomly) and then put in the turn method for the object you want to turn. When it says rotations, just put in the random number function found in world.functions and put Minimum: 0, Maximum: 1. This will make the person turn a random degree from where they are turning right now (it is your choice whether to turn them right or left, you can even make a random function for that too). Then for the distance you can also put in the random function and say put any minimum or maximum you want there.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
OwningDTW
Guest
 
Status:
Posts: n/a
Default 08-06-2010, 08:03 PM

Quote:
Originally Posted by Dameria View Post
Well if you want a person to randomly turn a certain degree, just make an if/else statement in the part where you want them to move (you can make it in an infinite loop if you want them to always move randomly) and then put in the turn method for the object you want to turn. When it says rotations, just put in the random number function found in world.functions and put Minimum: 0, Maximum: 1. This will make the person turn a random degree from where they are turning right now (it is your choice whether to turn them right or left, you can even make a random function for that too). Then for the distance you can also put in the random function and say put any minimum or maximum you want there.
Thanks for the response. My group members and I are still stumped, however, on the whole part of this assignment that requires us to trigger a common method to make an object disappear. I've read chapter 6 over and over and so have my group mates. We still can't figure this out.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 08-06-2010, 11:28 PM

That one is easy. I don't know exactly what you need to do for the program, but you need to use a parameter in your method. I will explain it as if your project was to make an object disappear when you click on it:

Create a "When mouse is clicked on something" event in the event panel and leave the rest of the event alone for now. Now create a world method and call it "disappear", or anything else you want to call it. In this method, create a parameter and make it an object parameter, call it "clickedObject". Now go to any object in the objects list you want and go to the properties. Look for the "opacity", and drag that into the "disappear" method, and make it turn to "0.0". It should now say "(objectName) set opacity to 0(0%)" in the method. Now, drag that parameter called "clickedObject" into the line of code where it says "(objectName)" so that it says "clickedObject set opacity to 0(0%)". Ok so now you are done with the disappear method. Now drag the "disappear" method from the method box into the mouse click event where it says "When mouse is clicked on Anything, do Nothing", you have to switch it out with the "Nothing" part.

It should be done now, just run the world and test it, and tell me if I missed anything or if its too confusing, I could create an example if you don't get it.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
zonedabone
Senior Member
 
zonedabone's Avatar
 
Status: Offline
Posts: 578
Join Date: Nov 2008
Location: In the interwebs
Default 08-10-2010, 10:19 AM

Setting up the objects:
Try putting all of your objects into a list.

The disappearing act:
  1. Create a new event.
  2. Add a parameter to it, called object, of type object.
  3. Now, you'll want to check if that object is in the list, so you don't delete the ground. Drag an if/else statement into the method, and then drag an a!=b statement into the criteria. a can be anything for now, but b must be -1. We will be comparing the first index of an element from the object list to it. -1means that the list does not contain the object. Drag your list of objects into the first section of the != statement, and select first index of, with the parameter being your object parameter from before.
  4. If that statement is true, it means that the list contains the object you clicked. Go to the properties of one of your objects and scroll down to the isShowing property. Drag this into your true section and set it to false. Click more and set duration to 0. Now drag your object parameter into the section before set isShowing. This will perform this action on the object parameter.
  5. It's now time to set up the event! Drag a when mouse is clicked on something event in, and leave anything as is. Now drag your new method into the event. For the parameter, use object under mouse cursor under expressions.
Random movement:
  1. This is a tricky one, but we'll get it. Make a new method, and have it preform on world start.
  2. Make a new variable in the method, a number variable to be exact.
  3. The first thing we need is an infinite loop, because we want the objects to move forever.
  4. Drag a for all together block from the same place as the loop blocks. The parameter will be your list of objects.
  5. Inside the block, set your variable to any number, but then drag the random function form the world's function list into the number slot. This will generate a random number between 0 and 1.
  6. Now drag the item_from_yourlist variable from the top of the block to the inside of the block. Select turn, and specify your variable as the number of revolutions. Now set the duration to you variable as well, and the style to abruptly.
  7. Now have the variable from the block move forward 1 meter.
  8. This function, if made correctly, should cause the objects to continue going randomly.


'Apple Macintosh' - An anagram of 'Complaints Heap'

M.A.C.I.N.T.O.S.H. - Machine Always Crashes, If Not, The Operating System Hangs.

You're *such* a mac person.
   
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 ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.