METHODS!.  A method is a sequence of instructions or behaviors that will be carried out when requested.  You can use them to create new methods so that.

Slides:



Advertisements
Similar presentations
Getting Started With Alice: The Basics By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
Advertisements

Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011.
Lesson 5+: Using He- Builder/She-Builder And Adding Text! Slides are adapted from aliceprogramming.net or
Princess & Dragon – Version 2 By Michael Hoyle under the direction of Professor Susan Rodger Duke University July 2012 Part 2: Using Methods.
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
Skater World: Part One By Deborah Nelson Duke University Under the direction of Professor Susan Rodger May 29,
How Tall Are You? Introducing Functions By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made June 2014 by.
Princess & Dragon Part 2: Teaching a Dragon to Fly—Methods & Properties By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
Lets Play Catch! Keeping Score in Alice By Francine Wolfe Duke University Professor Susan Rodger May 2010.
Lights Camera Action! Part 3: BDE Events By Deborah Nelson under the direction of Professor Susan Rodger Duke University July 2008.
Creating a 3D Interactive Story Prof. Susan Rodger Duke University Feb. 24, 2007.
Methods Tutorial: Part One By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 9, 2008.
Alice Learning to program: Part Two by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
Tutorial for Arrays and Lists By Ruthie Tucker. Description This presentation will cover the basics of using Arrays and Lists in an Alice world This presentation.
Making a Timer in Alice.
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June
Changing Camera Views! Part 2: Simple Scene Change & Lighting Fixes By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July.
3–D Helium Molecule Tutorial Alice Project Duke University Professor Susan H. Rodger Gaetjens Lezin June 2008.
Getting started with Alice Adapted from presentations by Jenna Hayes, Duke University Donna Gavin, UWP Computer Science and Software Engineering.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Teaching a character to walk in more than one world: Parameters and Inheritance. By Lana Dyck under the direction of Professor Susan Rodger Duke University.
Methods Tutorial: Part Two By Deborah Nelson Duke University Professor Susan Rodger June 16, 2008.
Now that the kangaroo and the turtle have raced, let's make a method for the kangaroo to hop back to the turtle and challenge him to a race again. Click.
By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
Animating Objects in Groups: Using Arrays and Lists By Ruthie Tucker under the direction of Professor Susan Rodger Summer 2008.
Lists Tutorial By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
A Simple Quiz: Ask User Functions. By Lana Dyck under the direction of Professor Susan Rodger Duke University June 2009, added Part 2 July 2011.
An Introduction to Alice (Short Version) – Extras! Yossra Hamid Under the Supervision of Professor Susan Rodger Duke University, June 2014 This is a continuation.
Making a Timer in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 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,
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
The Essentials of Alice (Bunny) By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
Illuminating Computer Science CCIT 4-6Sep
Creating a Historical Tour in Alice By Jenna Hayes May 2010.
The Essentials of Alice Mrs. Jayne Slease SBMS CTE Computer Science and Animation Credit to Duke Students under the direction of Professor Susan Rodger.
Tutorial for Arrays and Lists. Description This presentation will cover the basics of using Arrays and Lists in an Alice world It uses a set of chickens.
Changing Camera Views! Part 1: Set Point of View to By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July 2013 Updates.
Learning to Program: Part 1 Scene Setup and Starting Animation by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University,
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Using Placeholders to Simplify your Methods: Learning Methods, Part 2 By Deborah Nelson Duke University Professor Susan Rodger June 16, 2008.
Headshots in Alice Duke University Professor Susan H. Rodger Gaetjens Lezin July 2008.
Lesson 8C Animation and Events. Step 3: Animation Drag it into the method and have him say “let her go!” Click on the knight in the object tree and scroll.
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June.
How Tall Are You? Introducing Functions for Alice 3 By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made.
The Essentials of Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University May 2009.
Getting Started With Alice: The Basics. Step 1: Background Open up Alice, and choose a background for your Alice world. Your world is something you can.
Jonathon Kuo Under the Direction of Dr. Susan Rodger
The Essentials of Alice (Bunny)
Getting Started With Alice: The Basics
A Simple Quiz for Alice 3.2:
Teaching Characters to Walk: Learning Methods, Part 1
Professor Susan Rodger
Changing Camera Views! Part 1: Set Point of View to By Bella Onwumbiko
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
A Simple Quiz for Alice 3.2:
Methods Tutorial: Part Two
Princess & Dragon Part 2: Teaching a Dragon to Fly—Methods & Properties By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
Getting Started With Alice
Professor Susan Rodger
Headshots in Alice Duke University Professor Susan H. Rodger
Getting Started With Alice: The Basics
Using Placeholders to Simplify your Methods: Learning Methods, Part 2
Professor Susan Rodger
Presentation transcript:

METHODS!

 A method is a sequence of instructions or behaviors that will be carried out when requested.  You can use them to create new methods so that the characters can do more.  Built in methods are basic instructions every character already knows how to perform.  The two types of methods are class-level and world-level. PART 1: METHODSMETHODS

 A class-level method defines the behavior for a single character.  Step 1:How to create a class-level method 1)In our example world, click on the turtle in the object tree (upper left panel). 2)In turtle's details (lower left panel) click the methods tab and then the button create new method. Name it 'walk‘ PART 2: CLASS-LEVEL METHODS

 We want to move the turtle's legs back and forth as the turtle moves forward.  First, drag the control statement do in order, from the bottom of the window, into the editor.  This is the default setting for Alice, meaning that the instructions will be carried out in order, one after the other. STEP 2: HOW TO WRITE A METHOD

 Next, in the object tree, click on the + beside turtle to see the different body parts.  Drag the frontLeftLeg into the method. Select turn - backward. Choose other and type in 0.1 WRITING A METHOD (CONT 1) Turtle the turtle

 Finally, click more at the end of the turn command and choose duration =.25 seconds.  The default time for an action to be performed is 1 second. We are changing it to 0.25 so that it will happen faster.  Next, we want the turtle to move forward at the same time that the back leg goes forward  So drag in the control statement do together WRITING A METHOD (CONT 2)

 Finish dragging and dropping the instructions until your method looks like the picture below. Ask if you need help. WRITING A METHOD (CONT 3)

 Finally, add a comment to your method to tell someone reading your code what it does.  Your comment can say: "Move the turtles legs back and forth"  This comment is not Alice code.  It is simply an explanation for someone trying to understand your code. Alice ignores the comments when it plays your world. WRITING A METHOD (CONT 4) //This is a comment

 Click on world.myfirstmethod to get back to it and then drag turtle.walk into it.  Push the play button to watch the turtle walk. STEP 3: TO CALL YOUR METHOD

 Go to tutorial 2 in Alice  File  Open World  Click on the tutorial tab  Go to Tutorial2  Have fun! BUNNY TIME!

 Do on Your Own!  In the object tree, click on kangaroo. In kangaroo's details, click the button create new method and name it 'hop'  To write the method, drag and drop the instructions listed on the following slides  Your first step is to drag a do together into the method.  To find the lowerleg of the kangaroo, you click the + beside the leg tab. STEP 4: WRITING A METHOD FOR KANGAROO

KANGAROO.HOP METHOD (CONT 1)

 Remember, to call your method to test it.  Click on world.myfirstmethod to get back to it and then delete what you have there.  Drag kangaroo.hop into it.  Push the play button to watch the kangaroo hop. KANGAROO.HOP METHOD (CONT 2)

 A world-level method has characters that interact with each other. PART 3: WORLD-LEVEL METHODS

 In our example, we are going to write a method so that the turtle and the kangaroo race each other.  Click on world in the object tree. Click on the methods tab and the button create new method. Name it 'race'. STEP 5: WRITING A WORLD-LEVEL METHOD:

 First, we want the turtle to have a conversation with the kangaroo.  The first step is to drag a do in order into the method.  Then, click on turtle in the object tree and drag it into the method.  Put the following code into this method: WRITING A WORLD-LEVEL METHOD (CONT 1)

WRITING A WORLD-LEVEL METHOD (CONT 2)  Since we want the turtle and the kangaroo to move together, drag the control statement do together into the race method.  Click on turtle in the object area and click on method tab.

 Click on kangaroo in the object tree.  Drag kangaroo.hop into the do together under turtle.walk.  Click on world.myFirstMethod. Delete what you have there. WRITING A WORLD LEVEL METHOD (CONT 3)

 Click on 'world' in the object area and drag world.race into myFirstMethod. Push play.  The characters only move once.  If we repeatedly call the hop and walk methods in world.race, it will look more like a race.  Instead of dragging the instructions over multiple times, let's use a loop. PLAY YOUR WORLD

 One of the control statements is Loop. Drag Loop from the bottom of the window into the world.race method right above the do together. Select other and type in 4.  Below is what your code should look like. STEP 6: LOOPS

 When you push play, the Kangaroo will win the race.  Congratulations on creating one of your first methods!  Please save your work in your folder PLAY YOUR WORLD