SlideShare une entreprise Scribd logo
1  sur  38
Alice Learning to program: Part Two Writing Your Own Methods by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008 www.cs.duke.edu/csed/alice/aliceInSchools
Making Your Own Methods ,[object Object],[object Object]
Creating Your First Method ,[object Object],[object Object],[object Object]
Creating Your First Method ,[object Object],[object Object],[object Object],-Now click on the plus sign beside your character in the object list.  The parts should expand out.
Drag and Drop in this code. For example, click on  RightUpperArm  to see the methods for just this arm. Then, drag over the  roll  method, and set it to roll  left .18 revolutions . Repeat this process for  LeftUpperArm , choosing the opposite direction.
Final code ,[object Object]
Now click play. You should notice that nothing happens. Why is this? Look in the top right hand corner of your screen, and find where it says  when the world starts do .  Notice that it says, do  world.my first method . The method that you just wrote is called Jenna.cartwheel.
Playing Your New Method ,[object Object],[object Object],[object Object],[object Object],[object Object],This is a good way to test a method that you have just written.
Methods (Continued) ,[object Object],[object Object]
Methods (Continued) ,[object Object]
Positioning the Phone  ,[object Object],- Select  move to , and have the phone move to Jenna.  -This will simply position your object in your viewing screen. It will not change your code that you have written.
Positioning the Object ,[object Object],[object Object],- You should also try using quad view to make sure that the cellphone is very close to her pants, because it is hard to tell from the normal view.  Looks normal from here, but its actually far away.
[object Object],Glue Cellphone to Pocket
Vehicle Property  ,[object Object],[object Object],[object Object]
Method “answercellphone” ,[object Object],[object Object]
Method “answercellphone” ,[object Object]
Method “answercellphone” Here is the completed method.
Now you can try out your answercellphone method by going back to  when the world starts  and changing it to  Jenna.answercellphone .  Press play to see what it looks like.
-Your cellphone method may still look a little bit wrong. If Jenna’s phone looks like it is floating in the air, you should go back into quad view to reposition it so that it is right on her pocket. It may look right from the front, but when you view it from the side, you may see that the phone is actually several meters  away from Jenna.  -If your phone is not close enough to Jenna’s hand when she moves it up, for example if it is on her forearm, try using quad view to move the phone left and right to get the perfect position.
Method “Ride Horse” ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Playing Your “Ride Horse” Method -In order to see your Ride Horse method when you play your world, you need to change your  when the world starts  event again. Change it from  answercellphone  to  Ride Horse . -Each time you add code to  Ride Horse  you should play your world to test it out.
Method “Ride Horse” ,[object Object],Test this code by playing your world. If your characters arms do something other than moving down, you may have to try using a  turn  method instead of a  roll  method. This is because of the different sizes and shapes of the people-builder objects.
Method “Ride Horse” ,[object Object],You may need to adjust these numbers according to the position of your character. If Matt does not go up high enough, make him move farther up. If he goes up too far, don’t make him move quite as much.
If Matt looks like this, you may need to tell him to move up less, or move down more.
If Matt looks like this, you may need to tell him to move up more.
Method “Ride Horse” ,[object Object],[object Object],Add this code to the end of  Ride Horse .
Finishing “Ride Horse” ,[object Object],[object Object],[object Object],[object Object]
Now that you know how to write a method for a specific object, we are going to put these methods together to make a story. Click on the  world.my first method  tab on your screen. You may have code in there already from when you were testing out the he-builder/she-builder methods. You can keep it if you like, or erase it and add it back in later. These slides will start with a fresh, empty  my first method .
This is where we will keep the parts of our story. First, we will use the cartwheel method that we taught to Jenna. Click on  Jenna  in the list of objects on the left side of the screen, and then the  methods  tab to find cartwheel again. Drag cartwheel into  my first method.
In the right hand corner of your screen find where it says  when the world starts do , and change it to  world.my first method . This way whenever you play your world it will play the story we will have in  my first method .  Now play your world to see what it looks like so far. It should just show one of your characters cartwheeling.
Now we want to make our character say something. Look at the methods tab and scroll down until you see  say. Now drag it into  my first method  under cartwheel. Click on  other…  , and you will have to type in something for your character to say. Type in something like “I love cartwheels!”  Play your world again to see the results.
Now we want to change it so that your character cartwheels twice in a row, to show just how much she loves cartwheels. To do this, we will use a  loop .  The loop button is located at the bottom of your method editor. Drag it into  my first method  above cartwheel. When you drop it select  2 times .
Now drag and drop your cartwheel command inside the  Loop . In order to grab the cartwheel command to drag it, you must click on the left-most part of the method. Your cartwheel will now run 2 times! Play your world to see what happens.  Grab your method here to drag it.
You may feel that your character’s speech bubble disappears too quickly. If this is true, there is a way to make it last longer. Click on  more…  at the end of the say command. Then click on  duration.  As you can see, it lasts 1 second. You can make this longer if you wish, maybe 2 or 3 seconds.  Play your world to test out different durations until you find one you like.
Now we are going to add  comments . These are descriptions that you put in your code so that you, or anyone else that reads your code, can see what it does. The comment button is located at the bottom of the method editor. Drag it into the top of  my first method  and type a quick description of what your code does.
Now we will make your character answer her phone. Find the  answercellphone  method and drag it into  my first method.  Play your world again to see your changes.
Now we’ll add one more method to the story. Click on Matt, your other character, in the list of objects, and look at his methods until you find the RideHorse method. Add it to  my first method . Then add another comment above  answercellphone  that describes the rest of your code.
Congratulations on creating a great story! Now we are ready to move on to Part 3 to learn new things about changing the camera view.

Contenu connexe

Tendances

6.Production Reflection
6.Production Reflection6.Production Reflection
6.Production ReflectionHarvey Hyde
 
Flash cs4 tutorials_2009
Flash cs4 tutorials_2009Flash cs4 tutorials_2009
Flash cs4 tutorials_2009techbed
 
Tutorial 1 - Lightsaber Effect
Tutorial 1 - Lightsaber EffectTutorial 1 - Lightsaber Effect
Tutorial 1 - Lightsaber Effectairidascironka
 
Scratch Lesson 1 move with arrow keys
Scratch Lesson 1 move with arrow keysScratch Lesson 1 move with arrow keys
Scratch Lesson 1 move with arrow keysArtfulArtsyAmy
 
Photoshop_BlendingPhotos
Photoshop_BlendingPhotosPhotoshop_BlendingPhotos
Photoshop_BlendingPhotostutorialsruby
 
Final script for my thriller film
Final script for my thriller filmFinal script for my thriller film
Final script for my thriller filmjemimawright97
 

Tendances (9)

6.Production Reflection
6.Production Reflection6.Production Reflection
6.Production Reflection
 
Flash cs4 tutorials_2009
Flash cs4 tutorials_2009Flash cs4 tutorials_2009
Flash cs4 tutorials_2009
 
Toontastic pp
Toontastic ppToontastic pp
Toontastic pp
 
Tutorial 1 - Lightsaber Effect
Tutorial 1 - Lightsaber EffectTutorial 1 - Lightsaber Effect
Tutorial 1 - Lightsaber Effect
 
Scratch Lesson 1 move with arrow keys
Scratch Lesson 1 move with arrow keysScratch Lesson 1 move with arrow keys
Scratch Lesson 1 move with arrow keys
 
Tutorial 3
Tutorial 3Tutorial 3
Tutorial 3
 
Photoshop_BlendingPhotos
Photoshop_BlendingPhotosPhotoshop_BlendingPhotos
Photoshop_BlendingPhotos
 
Final script for my thriller film
Final script for my thriller filmFinal script for my thriller film
Final script for my thriller film
 
Kangaroo tutorial
Kangaroo tutorialKangaroo tutorial
Kangaroo tutorial
 

En vedette

En vedette (20)

The viisliam 4 in-1 flashlight is a must have
The viisliam 4 in-1 flashlight is a must haveThe viisliam 4 in-1 flashlight is a must have
The viisliam 4 in-1 flashlight is a must have
 
Tactical Flashlight Tips
Tactical Flashlight TipsTactical Flashlight Tips
Tactical Flashlight Tips
 
Karencheer
KarencheerKarencheer
Karencheer
 
Third term p.e
Third term p.eThird term p.e
Third term p.e
 
Flashlight friday rules
Flashlight friday rulesFlashlight friday rules
Flashlight friday rules
 
Gymnastics
GymnasticsGymnastics
Gymnastics
 
Gymnast
GymnastGymnast
Gymnast
 
The Best Of Gymnastics
The Best Of GymnasticsThe Best Of Gymnastics
The Best Of Gymnastics
 
Components of dance
Components of danceComponents of dance
Components of dance
 
GYMNASTICS (Paula y Mª Helena)
GYMNASTICS (Paula y Mª Helena)GYMNASTICS (Paula y Mª Helena)
GYMNASTICS (Paula y Mª Helena)
 
Descriptions
DescriptionsDescriptions
Descriptions
 
Gymnastics
GymnasticsGymnastics
Gymnastics
 
Gymnastics
GymnasticsGymnastics
Gymnastics
 
Five Important Things
Five Important ThingsFive Important Things
Five Important Things
 
A föld kora
A föld koraA föld kora
A föld kora
 
Gken
GkenGken
Gken
 
Uditha invite 120513
Uditha invite 120513Uditha invite 120513
Uditha invite 120513
 
1а презентация папы
1а презентация папы1а презентация папы
1а презентация папы
 
Blowing In The Wind
Blowing In The WindBlowing In The Wind
Blowing In The Wind
 
Timeless Treasure Marketing
Timeless Treasure MarketingTimeless Treasure Marketing
Timeless Treasure Marketing
 

Similaire à Alice Learning to program: Part Two Writing Methods and Creating a Story

Alice startpartone
Alice startpartoneAlice startpartone
Alice startpartonesumidahilo
 
Alice Start Part One
Alice Start Part OneAlice Start Part One
Alice Start Part OneCraig Perkins
 
Scratch Parrot Game
Scratch Parrot GameScratch Parrot Game
Scratch Parrot Gamejenloudun
 
We are going to learn to program!
We are going to learn to program!We are going to learn to program!
We are going to learn to program!jenloudun
 
Maze tutorial
Maze tutorialMaze tutorial
Maze tutorialJWhiteley
 
Character Rigging Animation Tutorial with Custom Rigg Controller
Character Rigging Animation Tutorial with Custom Rigg ControllerCharacter Rigging Animation Tutorial with Custom Rigg Controller
Character Rigging Animation Tutorial with Custom Rigg ControllerGameyan Studio
 
Scratch parrot shoot game
Scratch   parrot shoot gameScratch   parrot shoot game
Scratch parrot shoot gamemrsharma2015
 
How to Andy Warhol Your Face
How to Andy Warhol Your FaceHow to Andy Warhol Your Face
How to Andy Warhol Your FaceDeclanTyldsley
 
04 Car race track game
04   Car race track game04   Car race track game
04 Car race track gamemrsharma2015
 
Feedback of Fourth Draft
Feedback of Fourth DraftFeedback of Fourth Draft
Feedback of Fourth Draftguest8722d5
 
Overall progress - barry
Overall progress - barryOverall progress - barry
Overall progress - barrycrimzon36
 
Scratch for kids syllabus for 5 hours by bibek pandit
Scratch for kids syllabus for 5 hours by bibek panditScratch for kids syllabus for 5 hours by bibek pandit
Scratch for kids syllabus for 5 hours by bibek panditBibekPandit2
 

Similaire à Alice Learning to program: Part Two Writing Methods and Creating a Story (20)

Alice startpartone
Alice startpartoneAlice startpartone
Alice startpartone
 
Alice Start Part One
Alice Start Part OneAlice Start Part One
Alice Start Part One
 
Scratch Parrot Game
Scratch Parrot GameScratch Parrot Game
Scratch Parrot Game
 
Bai5
Bai5Bai5
Bai5
 
We are going to learn to program!
We are going to learn to program!We are going to learn to program!
We are going to learn to program!
 
Maze tutorial
Maze tutorialMaze tutorial
Maze tutorial
 
Character Rigging Animation Tutorial with Custom Rigg Controller
Character Rigging Animation Tutorial with Custom Rigg ControllerCharacter Rigging Animation Tutorial with Custom Rigg Controller
Character Rigging Animation Tutorial with Custom Rigg Controller
 
my robot
my robotmy robot
my robot
 
Scratch parrot shoot game
Scratch   parrot shoot gameScratch   parrot shoot game
Scratch parrot shoot game
 
How to Andy Warhol Your Face
How to Andy Warhol Your FaceHow to Andy Warhol Your Face
How to Andy Warhol Your Face
 
Work flow
Work flowWork flow
Work flow
 
04 Car race track game
04   Car race track game04   Car race track game
04 Car race track game
 
Feedback of Fourth Draft
Feedback of Fourth DraftFeedback of Fourth Draft
Feedback of Fourth Draft
 
Overall progress - barry
Overall progress - barryOverall progress - barry
Overall progress - barry
 
Kids liketocode
Kids liketocodeKids liketocode
Kids liketocode
 
Modul 1 Scratch
Modul 1 ScratchModul 1 Scratch
Modul 1 Scratch
 
How do i
How do iHow do i
How do i
 
Scratch for kids syllabus for 5 hours by bibek pandit
Scratch for kids syllabus for 5 hours by bibek panditScratch for kids syllabus for 5 hours by bibek pandit
Scratch for kids syllabus for 5 hours by bibek pandit
 
Photoshop Guide
Photoshop GuidePhotoshop Guide
Photoshop Guide
 
Coding scratch
Coding scratchCoding scratch
Coding scratch
 

Dernier

Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 

Dernier (20)

Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 

Alice Learning to program: Part Two Writing Methods and Creating a Story

  • 1. Alice Learning to program: Part Two Writing Your Own Methods by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008 www.cs.duke.edu/csed/alice/aliceInSchools
  • 2.
  • 3.
  • 4.
  • 5. Drag and Drop in this code. For example, click on RightUpperArm to see the methods for just this arm. Then, drag over the roll method, and set it to roll left .18 revolutions . Repeat this process for LeftUpperArm , choosing the opposite direction.
  • 6.
  • 7. Now click play. You should notice that nothing happens. Why is this? Look in the top right hand corner of your screen, and find where it says when the world starts do . Notice that it says, do world.my first method . The method that you just wrote is called Jenna.cartwheel.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17. Method “answercellphone” Here is the completed method.
  • 18. Now you can try out your answercellphone method by going back to when the world starts and changing it to Jenna.answercellphone . Press play to see what it looks like.
  • 19. -Your cellphone method may still look a little bit wrong. If Jenna’s phone looks like it is floating in the air, you should go back into quad view to reposition it so that it is right on her pocket. It may look right from the front, but when you view it from the side, you may see that the phone is actually several meters away from Jenna. -If your phone is not close enough to Jenna’s hand when she moves it up, for example if it is on her forearm, try using quad view to move the phone left and right to get the perfect position.
  • 20.
  • 21. Playing Your “Ride Horse” Method -In order to see your Ride Horse method when you play your world, you need to change your when the world starts event again. Change it from answercellphone to Ride Horse . -Each time you add code to Ride Horse you should play your world to test it out.
  • 22.
  • 23.
  • 24. If Matt looks like this, you may need to tell him to move up less, or move down more.
  • 25. If Matt looks like this, you may need to tell him to move up more.
  • 26.
  • 27.
  • 28. Now that you know how to write a method for a specific object, we are going to put these methods together to make a story. Click on the world.my first method tab on your screen. You may have code in there already from when you were testing out the he-builder/she-builder methods. You can keep it if you like, or erase it and add it back in later. These slides will start with a fresh, empty my first method .
  • 29. This is where we will keep the parts of our story. First, we will use the cartwheel method that we taught to Jenna. Click on Jenna in the list of objects on the left side of the screen, and then the methods tab to find cartwheel again. Drag cartwheel into my first method.
  • 30. In the right hand corner of your screen find where it says when the world starts do , and change it to world.my first method . This way whenever you play your world it will play the story we will have in my first method . Now play your world to see what it looks like so far. It should just show one of your characters cartwheeling.
  • 31. Now we want to make our character say something. Look at the methods tab and scroll down until you see say. Now drag it into my first method under cartwheel. Click on other… , and you will have to type in something for your character to say. Type in something like “I love cartwheels!” Play your world again to see the results.
  • 32. Now we want to change it so that your character cartwheels twice in a row, to show just how much she loves cartwheels. To do this, we will use a loop . The loop button is located at the bottom of your method editor. Drag it into my first method above cartwheel. When you drop it select 2 times .
  • 33. Now drag and drop your cartwheel command inside the Loop . In order to grab the cartwheel command to drag it, you must click on the left-most part of the method. Your cartwheel will now run 2 times! Play your world to see what happens. Grab your method here to drag it.
  • 34. You may feel that your character’s speech bubble disappears too quickly. If this is true, there is a way to make it last longer. Click on more… at the end of the say command. Then click on duration. As you can see, it lasts 1 second. You can make this longer if you wish, maybe 2 or 3 seconds. Play your world to test out different durations until you find one you like.
  • 35. Now we are going to add comments . These are descriptions that you put in your code so that you, or anyone else that reads your code, can see what it does. The comment button is located at the bottom of the method editor. Drag it into the top of my first method and type a quick description of what your code does.
  • 36. Now we will make your character answer her phone. Find the answercellphone method and drag it into my first method. Play your world again to see your changes.
  • 37. Now we’ll add one more method to the story. Click on Matt, your other character, in the list of objects, and look at his methods until you find the RideHorse method. Add it to my first method . Then add another comment above answercellphone that describes the rest of your code.
  • 38. Congratulations on creating a great story! Now we are ready to move on to Part 3 to learn new things about changing the camera view.