Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and...
Transcript of Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and...
![Page 1: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/1.jpg)
Session 10 Alice Hands On Slides
>_ {Code4Loop};Roochir Purani
![Page 2: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/2.jpg)
Download Alice 3.2!
• You can get it at Alice.org
• Click downloads > Get Alice 3.1 or 3.2
• Select an installer for your operating system.
![Page 3: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/3.jpg)
When you’ve got it running…• You’ll see a screen like this:
• Select Grass, then click OK
![Page 4: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/4.jpg)
The Interface
v Scene View
^ The Methods Panel
Code Editor Panel
![Page 5: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/5.jpg)
The Scene View
• The scene view at the top left gives a view of our world.
• Right now it’s just an empty swamp, but we’re about to add dragons, witches, and more!
![Page 6: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/6.jpg)
Making a Scene• Click on Setup Scene at the bottom right of the scene view to add objects
to your scene.
![Page 7: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/7.jpg)
Making a Scene• Now you’ll see the interface for adding objects
• The scene view is still there, but now you’ll see a list of object galleries at the bottom
• Objects are sorted by the way they move (flyers, swimmers, etc.), or by theme.
![Page 8: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/8.jpg)
Making a Scene• There’s also a pane on the
right that will let us move and change objects once we add them.
Move
Change
![Page 9: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/9.jpg)
Making a Scene• Now, click the Browse Gallery By Group tab above the list of galleries so
we can add in a bunch of “fantasy” objects.
![Page 10: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/10.jpg)
Start with a new world• Add a bunny, a camel, and several animals of
different heights, spread around the world
• I picked bunny, camel, chicken, fox, peacock, caiman– any animals will do but make sure you have some tall animals.
![Page 11: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/11.jpg)
Problem
• The bunny wants to visit each animal where “visit” means: the bunny and the animal face each other, the bunny moves close in front of it, the bunny says “hi” and then the bunny jumps over it. However, the bunny can only jump 1 meter high.
![Page 12: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/12.jpg)
Parts of the Tutorial
• Part 1: Bunny visit each friend
• Part 2: Bunny either go around or jump over
• Part 3: Create an event to click on animal to visit
![Page 13: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/13.jpg)
Part 1: bunny visitcamel
• Create a “bunny” method called visit for the bunny to visit the camel
![Page 14: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/14.jpg)
Part 1: bunny visit camel• At the top of the method editor, click on Add a Parameter.
• A parameter is a piece of information that helps the method work. Inthis case, the information we want to know is which friend the bunnyis visiting (the camel), so name the parameter FriendToVisit
![Page 15: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/15.jpg)
Part 1: bunny visit camel
• Click on value type of the parameter, and find the SModel in the object tree. Click OK .
![Page 16: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/16.jpg)
• The bunny visit method should now look like this:
Part 1: bunny visit camel
• Now, you try to add the following code:
– Bunny turns to face the friendToVisit
– friendToVisit turns to face the bunny
– Bunny moves forward 1 meter
![Page 17: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/17.jpg)
Enter the following code• The bunny turns to visit the friendToVisit and moves
toward it.
• To test it out, add “this.bunny.visit” to myFirstMethod, pick the camel as FriendToVisit, and PLAY
![Page 18: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/18.jpg)
How to move the bunny all the way to
the camel• Click on bunny, click on Functions.
• Click and drag “this distance to”, (choose FriendToVisit) on top of the 1 meter.
![Page 19: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/19.jpg)
Resulting in….
• Click Play
• Yikes, The bunny goes into the camel!
• We want the bunny to stop 2 meters in front of the camel (make sure the camel is more than 2 m away).
![Page 20: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/20.jpg)
Use Math and subtract 2
• Click on white arrow
• Select “math”, then “minus sign” then “2”
![Page 21: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/21.jpg)
Resulting in the followingcode
•The bunny will stop two meters in front of the center of the camel…
•Try out the code!
![Page 22: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/22.jpg)
Next add a greeting and jumpover
• Have the bunny say a greeting
• Then have the bunny jump over the camel– The bunny must jump up
– The bunny must jump 1m to the camel, plus the camel’s depth, plus another 1m past the camel• Total distance: 2 + camel’s depth
• Find camel’s depth in the camel functions…
– The bunny jumps down
(code on the next page)
![Page 23: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/23.jpg)
Add the remaining code Change “when the world starts” to
bunny.visit and “Play”
![Page 24: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/24.jpg)
Go to myFirstMethod, and have the bunny visit all of their animal friends!
![Page 25: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/25.jpg)
Add another parameter of type String so bunny can
give a different greeting to each animal
• Click on the tab for bunny.visit first
• Click on “add parameter”
• The type is “TextString” since the bunny will say worlds
•The name is
“greeting”
![Page 26: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/26.jpg)
The result is…
• Now click and drag “greeting” over the phrase the bunny says “Hello”
• Result is:
![Page 27: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/27.jpg)
Back to MyFirstMethod, addgreetings
• Replace “greeting=unset” to a different greeting for each animal.
• Then Click Play
![Page 28: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/28.jpg)
Part 2: Going around or overfriend
• bunny 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
![Page 29: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/29.jpg)
First drag in an If/Else from the bottom of the window, placing after the “say”
![Page 30: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/30.jpg)
Select “true”, “Relational DecimalNumber”, less than “<“ symbol,
and select 0.5 for the first number and 1 for the second number.
![Page 31: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/31.jpg)
Using functions, replace 0.5 with the FriendToVisit’sheight
![Page 32: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/32.jpg)
Move the bunny jump over code and put after the if. Then add code after
the else to “go around”.Then Play
![Page 33: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/33.jpg)
Part 3 – create an event to visit the friend clicked on
• To stop the movie from playing as is, go to InitializeEventListeners, and delete myFirstMethod from sceneActivated. You can add it back in later.
![Page 34: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/34.jpg)
Click on Add Event Listener, Mouse, and
“addMouseClickOnObjectListener”
![Page 35: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/35.jpg)
Drag over the visit code into the do in order and select any animal as friendToVisit.
Drag “getModelAtMouseLocation”
over the animal
![Page 36: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/36.jpg)
Now click “play” and click on different animals, but not the bunny…
• The bunny will go visit the animal you click on.
• Click on another animal and it will go visit that animal.
![Page 37: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/37.jpg)
Exporting to a MOVIE File
Click on File Menu, Then Upload to Youtube. This will ask you to record the movie and you can recordthe interactions.
![Page 38: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/38.jpg)
Exporting to a Movie file
• After recording the movie with user interaction, you can export the file to a video
• Or upload to the youtube.
![Page 39: Session 10 Alice Hands On Slides - > code4loop; · • Click on value type of the parameter, and find the SModel in theobject tree. ... –Bunny moves forward 1 meter. Enter the](https://reader034.fdocuments.net/reader034/viewer/2022042109/5e896b4cc3925e2b56523e32/html5/thumbnails/39.jpg)
Great Work!