Alice Community Help with project

 Help with project
 seanr25 Junior Member   Status: Offline Posts: 13 Join Date: Jan 2013 Help with project - 02-22-2013, 11:17 AM I am suppose to write a hop method that makes it hop in a realistic fashion with a parameter that lets the sender of the message specify how far the animal should hop. I have made the hop method, and I am satisfied with how it looks, but I can't seem to make the right parameter to make it hop all the way to the Joey. I have created the parameter and called it "distanceToHop", and I have tried several different things to get it to work, but it only hops once. I know how to use the move method to get it to move, but it only slides across the ground to the Joey. I need it to hop "realistically" to the Joey..... If I had any hair left, I would be ready to pull it out!!! lol Any help would be appreciated!
 File
seanr25
Junior Member

Status: Offline
Posts: 13
Join Date: Jan 2013
File - 02-22-2013, 11:19 AM

Sorry, I forgot to attach my file.
Attached Files
 kangaroo hop.a2w (443.5 KB, 4 views)

 bob3584 Senior Member   Status: Offline Posts: 180 Join Date: Jan 2013 Location: In a Cardboard Box. 02-22-2013, 07:01 PM When do you need it done? My avatar will always be a preview of what I am currently working on.
 Using parameters...
 chickentree Super Moderator   Status: Offline Posts: 250 Join Date: Dec 2012 Location: Frosno, Ca Using parameters... - 02-23-2013, 12:06 PM Start by looking at what you have so far. The Kangaroo is hopping 12 times using your hop method after that you calculate the distance to Joey and have the Kangaroo move forward that far. The last instruction is why the Kangaroo is moving instead of jumping. Your hop method needs a couple of things, look at parameters how to define and use them. Add a parameter to hop which takes the distance the kangaroo has to move in meters. Then replace the 12 (times) in your loop with the parameter. Alice will automagically throw away anything after the decimal point when a value is used in a loop in this way. Since most things are reported in meters, you probably want to change hop so that the Kangaroo will move forward 1 meter each hop. Hint: I would not change the present move forward instruction. I would add another one just like it somewhere else in the method. So now you have a method (hop) with a parameter that takes a number. What do you do with it? Move the instruction calculating the distanceToHop value to before the call to Kangaroo.hop. Kangaroo.hop should now have a parameter (probably set to 1 by default) replace the value with your variable distanceToHop. Finally delete the Kangaroo move forward instruction in "My first method" and run the program. Final note: You might want to have the kangaroo turn the face Joey before starting to hop.

 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