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.

Slides:



Advertisements
Similar presentations
Visual Lists By Chris Brown under Prof. Susan Rodger Duke University July 2012.
Advertisements

Space Man Sam: Grammar Mistakes By Aleis Murphy Duke University, Under the direction of Professor Susan Rodger July 2010.
Objects in Alice: Positioning and Moving Them By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
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,
Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
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.
Calvin and Hobbes Teach Properties and Functions Created by Daniel MacDonald under the direction of Professor Susan Rodger Duke University June 2013.
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.
Checking for Collisions Ellen Yuan Under the direction of Professor Susan Rodger at Duke University June 2014.
Distributing (Fun + Learning): The Distributive Property By: Peggy Li Under the direction of Professor Susan Rodger Duke University, June
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
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
3–D Helium Molecule Tutorial Alice Project Duke University Professor Susan H. Rodger Gaetjens Lezin June 2008.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Poses Tutorial Alex Boldt Under the direction of Professor Susan Rodger Duke University July 2015.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
By Deborah Nelson Duke University Professor Susan Rodger July 13, 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.
Balancing the scales: Inequalities By Melissa Dalis Professor Susan Rodger Duke University June 2011.
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.
Creating a 3D Interactive Story Prof. Susan Rodger Duke University July 19, 2007.
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.
Skater World: Part Three By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 2009.
An Introduction to Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University, June 2009 Updated June 2014 by Ellen Yuan.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Illuminating Computer Science CCIT 4-6Sep
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.
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.
A Simple Quiz for Alice 3.2:
An Introduction to Alice (Short Version)
Teaching Characters to Walk: Learning Methods, Part 1
Changing Camera Views! Part 1: Set Point of View to By Bella Onwumbiko
Changing Color, Using Text Objects, and Random Selection in Alice
Let's Race! Typing on the Home Row
A Simple Quiz for Alice 3.2:
Making Objects Move in Unison: Using Lists
Princess & Dragon Part 2: Teaching a Dragon to Fly—Methods & Properties By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
An Introduction to Alice
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events
How Tall Are You? Introducing Functions
Professor Susan Rodger
Headshots in Alice Duke University Professor Susan H. Rodger
Alice and Daisies: Positioning and Moving Objects in Alice
Using Placeholders to Simplify your Methods: Learning Methods, Part 2
Professor Susan Rodger
Making Objects Move in Unison: Using Lists
Presentation transcript:

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 June 2009

Introduction and Setup This tutorial will demonstrate how to teach a character to walk to any object in a world by using parameters. It will also show how to copy that same character, including the new walk skill, into a new world using inheritance. Open a new Alice snow world. Click on Add Objects. Choose Local Gallery, and click people. Add one of each into your world: EskimoGirl, Snowman, SnowWoman. Place the characters so there is some space between them and they are facing the camera. Let's get started by setting up the first world.

Enter in 0.15 and click Okay Now roll the leftUpperArm to the left by 0.15 revolutions. We now need to move the eskimoGirls arms down. In the object tree click on eskimoGirl and the right click on rightUpperArm. Under methods go to eskimoGirlrightUpperArm roll, right and other... Click the green Done button when finished Introduction and Setup

Now we will teach eskimoGirl to walk toward the snowman. To do this we will create a new method that will have her face the snowman, turn her arms and legs and move forward until she reaches him. Step 1: Teaching eskimoGirl to walk Lets start by creating a walk method. Click on eskimoGirl in the object tree. In the details area click on the methods tab and click on create a new method Name the new method: walk.

The first action eskimoGirl needs to perform is to turn and face where she will be walking. Step 1: Teaching eskimoGirl to walk Continued... Under the eskimoGirl methods, click on turn to face and drag into the methods edit area. Choose the entire snowman.

Next let's work out how eskimoGirl's arms and legs should move to create a walking motion. If you watch someone walking on a treadmill their right leg moves forward with their left arm, while their left leg and right arm appear to move backwards. First add a Do together block to the method. Then add the right leg movement. Select rightUpperLeg under the eskimoGirl in the object tree. Drag and drop the turn method into the Do together block. Select forward and enter in 0.1 revolutions. Step 2: EskimoGirl's First Step

Add in the other methods for arm and leg motions, and move eskimoGirl forward. Your method should look similar to this. Step 2: EskimoGirl's First Step Continued...

To see how this method works, click on world.my first method then drag and drop the walk method into the method edit area. Click on play to see what happens. Step 2: EskimoGirl's First Step Continued...

Now lets bring eskimoGirl's arms and legs back into the standing position to complete the first step. To do this we need to go back to the walk method and add the next Do together block. Note: You may notice that the right leg looks like it is going backward, when the instructions say forward. This is based on how this object was originally set up by the Alice developers. It will not affect the walking method as long as you keep the directions consistent Step 2: EskimoGirl's First Step Continued...

Complete the Do together block by adding the leg and arm movements and reverse their direction. Your control statement should look similar to this. Go ahead and play the world to see eskimoGirl's first step. Step 2: EskimoGirl's First Step Continued...

For the second step we want to bring the left leg forward and then complete the step by bringing the right leg forward. Let's take a short cut and copy the control statements we already have. To make a copy of the do together that moves the left leg forward, right click on the do together box and select make copy. You can then drag and drop the new do together to where you want it to go. In this case move it to the end of the method. Step 3: EskimoGirl's Second Step

There is another way to make a copy of a control statement by using the clipboard. Let's make a copy of the Do together block that moves the right leg forward. Drag and drop the block onto the clipboard at the top right hand side of the window. The clipboard will now have a white paper on it to show something is ready to be pasted. Step 3: EskimoGirl's Second Step Continued...

To paste from the clipboard, drag and drop the white paper from the clipboard to where you want it in your method. In this case you want to place it at the very end of the method. Now play the world to see eskimoGirl take two steps toward the snowman. Step 3: EskimoGirl's Second Step Continued... Note: If eskimoGirl has already reached the snowman, go into add objects and move eskimoGirl farther away.

Now we want eskimoGirl to walk to the snowman by repeating the control statements over and over again until she reaches the snowman. Rather than simply copying the statements again and again we can use a Loop or a While statement. Step 4: Completing the Walk Method Let's use the While statement so the eskimoGirl can walk while she has not yet reached the snowman. Drag and drop the While control statement to the top of the walk method and select true.

Under eskimoGirl's functions drag is at least away from to the true on the While statement. Select 1 meter away from the entire snowman. Step 4: Completing the Walk Method Continued...

Now drag and drop all the control statements we have made into the While loop. Be sure to do them in order. Play your world and watch the eskimoGirl walk all the way to the snowman. Note: You may have to adjust the is at least number to have the eskimoGirl stop where you want her to. Step 4: Completing the Walk Method Continued...

Now lets change the walk method to be more flexible so we can use it to have eskimoGirl walk to any object we choose. To do this parameters can be added. A parameter is like a basket that receives information that we send to a method. We will use parameters to tell the walk method where we want eskimoGirl to walk to and how close we want her to get. Then we can ask her to walk to within 1 meter of snowman or within 1 meter of snowWoman using the same method. Step 5: Creating parameters parameter information

There are many different types of information a parameter can hold including, Numbers, Objects and Booleans. Numbers can be positive or negative and include decimals. Objects include anything that can be listed in the object tree. Boolean (pronounced ˈbü-lē-ən) is a special type that can only be TRUE or FALSE. IMPORTANT: parameters can only hold one piece of information and it must be the exact type of information it was designed to hold. Note: We won't be exploring boolean in this tutorial, but this type can be helpful when you are exploring parameters in the future. Step 5: Creating parameters Continued...

So lets get started.... First, create a parameter to hold the information on which object eskimoGirl should walk to. Click on create new parameter. In the pop-up box enter in the name destination, and select the type Object. This means we only want to accept information about the object in this parameter. Click on OK to create the new parameter Step 5: Creating parameters Continued...

Notice how the parameters show what type of information they are expecting: an object, or a number Next create a parameter to hold the information about the distance. This is the distance from the object to the eskimoGirl. Click on create new parameter. In the pop-up box enter in the name distanceFrom, and select the type Number. This means we only want to receive information about a number in this parameter. Click on OK to create the new parameter Step 5: Creating parameters Continued...

Now let's replace the parts in the method that specifically mention the snowman with the destination parameter. There are two places. Drag the destination parameter over the word snowman in the While statement Drag the destination parameter over the snowman word in the turn to face statement and select destination. Step 6: Adding Parameters to the Method

You have now added parameters to your method. However, you will not be able to play your world. Go to my first method and take a look at what has happened to the method. Now drag the distanceFrom parameter over the 1 meter word in the While statement Step 6: Adding parameters Continued...

In my first method the eskimoGirl's walk method now shows the two parameters that were added. We need to send these parameters the correct information before the world can be played. Click on the destination and select the entire snowman. The distanceFrom default number is 1. Let's leave this number for now. Step 6: Adding parameters Continued...

Now we can have the eskimoGirl walk to any object in our world. Add another eskimoGirl walk method to my first method and select the entire snowWoman with a distanceFrom of 1. Play your world and see what happens. Note: You may have to adjust the distanceFrom amount to have the eskimoGirl stop where you want her to. Step 6: Adding parameters Continued...

EskimoGirl is now tired of the snow and wants to go to the beach. The rest of this tutorial will show you how save our new eskimoGirl and bring her into a beach world. Let's rename eskimoGirl to show that she can perform more skills. Step 7: Inheritance In the object tree right click on eskimoGirl and select rename. Change the name to cleverEskimoGirl

To add the new cleverEskimoGirl into a different Alice world we need to save her as a new 3D model class. Okay, let's take a step back so we can figure out what a class is all about. Perhaps you noticed that the objects in the Gallery are called a class. Step 7: Inheritance Continued... A class is a specific kind of object. Every object that comes from this class knows how to do the same things, it has the same methods. For example we only needed to teach cleverEskimoGirl how to do one thing, walk. She already knew how to do all the things the class eskimoGirl knew how to do. CleverEskimoGirl inherited all the properties and methods from the class eskimoGirl. Inheritance is when a new class is based on a class that already exists.

To save cleverEskimoGirl as a new class, right click on cleverEskimoGirl and select save object... Save the file in a place where you can find it later. To use the cleverEskimoGirl in a new world we need to save the her as a new 3D model class. This means a copy of cleverEskimoGirl, can be added into a new world. Step 7: Inheritance Continued...

While in the add objects window you will add an object of the cleverEskimoGirl. Under the File menu at the top right of the window select Import... Find the file called cleverEskimoGirl and select it. Position the objects to look something like this. Start a new sand world, and add two beachChair objects from the beach gallery Step 8: Importing from a new Class

Under the cleverEskimoGirl methods add walk into the my first method. Have the cleverEskimoGirl walk to each beachChair with a distanceFrom of 1.5 Now play your world and watch the cleverEskimoGirl walk to each beachChair. Step 9: Finishing Up