1 / 20

Tutorial on Kangaroo visiting his animal friends - parameters, events

Tutorial on Kangaroo visiting his animal friends - parameters, events. Start with new world. Add a Kangaroo and several animals of different heights, spread around the world I picked bunny, cow, horse1, ladybug, tortoise, turtle – any animals will do. Problem.

shirin
Télécharger la présentation

Tutorial on Kangaroo visiting his animal friends - parameters, events

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tutorial on Kangaroo visiting his animal friends- parameters, events

  2. Start with new world • Add a Kangaroo and several animals of different heights, spread around the world • I picked bunny, cow, horse1, ladybug, tortoise, turtle – any animals will do

  3. Problem • The kangaroo wants to visit each animal where “visit” means: the kangaroo and the animal face each other, the kangaroo moves close in front of it, the kangaroo says “hi” and then the Kangaroo jumps over it. However, the kangaroo can only jump 1 meter high.

  4. Parts of the Tutorial • Part 1: Kangaroo visit each friend • Part 2: Kangaroo either go around or jump over • Part 3: Create an event to click on animal to visit

  5. Part 1: Kangaroo visit Cow • Create a “Kangaroo” method called visit

  6. See the new Kangaroo visit method

  7. Enter the following code • For the third line • drop the move forward first • under “kangaroo”, “functions”, drag in “distance to” and drop over the number • Then click on the last white arrow on the line to select “Math” and then the minus and 2 • The kangaroo will stop two meters in front of the center of the cow…

  8. Add the remaining codeChange “when the world starts” toKangaroo.visit and “Play”

  9. How to visit any friend –Add a parameter named friendToVisit- type should be Object – click ok 2. 1.

  10. Now click and drag friendToVisit on top of the four occurances of Cow Click and drag from here

  11. Change “when the world starts” back to myFirstMethodDrag in visit for each friend and “Play”

  12. Part 2: Going around or over friend • Kangaroo can only jump 1 meter high • If friend is shorter than 1 meter, it is ok to jump over • If friend is 1 meter or taller, then go around them

  13. First drag in an If/Else from the bottom of the window, placing after the “say”

  14. Select “world”, “functions” and scroll to find math functions, then click and drag “a<b” selecting 1’s

  15. Drag in “cow’s height” from the cow functions, then drop “friendToVisit” over cow

  16. Move the kangaroo jump over code and put after the if. Then add code after the else to “go around”. Then Play

  17. Part 3 – create an event to visit friend clicked onFirst, disable code in myFirstMethod

  18. Create a new eventWhen the mouse is clicked on something

  19. Drag over the visit code and select “expressions”, “object under mouse cursor”

  20. Here is the event.Now click “play” and click on different animals, but not the kangaroo…

More Related