Using Functions in Alice

Slides:



Advertisements
Similar presentations
Objects in Alice: Positioning and Moving Them By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
Advertisements

Princess & Dragon – Version 2 By Michael Hoyle under the direction of Professor Susan Rodger Duke University July 2012 Part 2: Using Methods.
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.
Using Functions in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University July 2008.
Using Functions in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University July 2008.
Class-Level Variables in Alice By Jenna Hayes Under the direction of Professor Rodger Duke University, July 2008.
Wizard Game: Class-Level Variables in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July
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.
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.
Creating Functions Deborah Nelson Duke University Professor Susan Rodger July 22, 2008.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Making a Timer in Alice.
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
Changing Camera Views! Part 2: Simple Scene Change & Lighting Fixes By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July.
Getting started with Alice Adapted from presentations by Jenna Hayes, Duke University Donna Gavin, UWP Computer Science and Software Engineering.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Tutorial on Kangaroo visiting his animal friends - parameters, events.
Animating Objects in Groups: Using Arrays and Lists By Ruthie Tucker under the direction of Professor Susan Rodger Summer 2008.
Making a Timer in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
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.
Creating a 3D Interactive Story Prof. Susan Rodger Duke University July 19, 2007.
Tutorial on Kangaroo visiting his animal friends - parameters, events Susan Rodger Duke University 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.
CompSci 4 Chap 6 Sec 2 Sep 30, 2010 Prof. Susan Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not a Flutterbudget.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Illuminating Computer Science CCIT 4-6Sep
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.
Tutorial on Bunny visiting his animal friends - parameters, events for Alice 3 Susan Rodger Duke University June 2009 Updated by Yossra Hamid on October.
DAY 4. MAKING SOMETHING ‘JUMP’ Simple! Move it a certain amount ‘up’ Glide back to your original spot.
The Essentials of Alice (Bunny)
Class-Level Variables in Alice
Getting Started With Alice: The Basics
An Introduction to Alice (Short Version)
Teaching Characters to Walk: Learning Methods, Part 1
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
Changing Color, Using Text Objects, and Random Selection in Alice
Simple Control Structures
Tutorial on Kangaroo visiting his animal friends - parameters, events
Let's Race! Typing on the Home Row
Michelle Venable-Foster Barb Ericson Jan 2007
Methods Tutorial: Part Two
Objects in Alice: Positioning and Moving Them
Making Objects Move in Unison: Using Lists
Checking for Collisions: Using Functions in Alice
Shark vs. TRex: Understanding “AsSeenBy” In Alice By Jenna Hayes
An Introduction to Alice
Restricting an Event with a Conditional
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events
How Tall Are You? Introducing Functions
Professor Susan Rodger
Using Alice This is an introduction to Alice..
Getting Started With Alice: The Basics
Alice and Daisies: Positioning and Moving Objects in Alice
Using Placeholders to Simplify your Methods: Learning Methods, Part 2
Lesson One: Objects in Alice: Positioning and Moving Them
Professor Susan Rodger
Shark vs. TRex: Understanding “AsSeenBy” In Alice By Jenna Hayes
under the direction of Professor Susan Rodger
Restricting Events Creating Conditional Events in Alice By Henry Qin
Presentation transcript:

Using Functions in Alice

Step 1: Understanding Functions 2. 1. Download the starting world that goes along with this tutorial. We will be using functions. A function in Alice is basically a question about information in your Alice world that Alice answers. Click on the penguin object in the object tree. Then click on the functions tab. You will see a LONG list of functions. Scroll down and look at the functions under size. These functions can be very useful in Alice. What if, for example, you want to make something move up and stand on top of the penguin’s head? You don’t know how exactly how tall the penguin is. But Alice does!

Step 2: Using the True or False Functions We are going to add commands so that when the Alice world starts, if the penguin is taller, it will say “Hah! I’m taller!”, but if the normalGuy is taller, he will say, “Hah! I’m taller!”. Some functions in Alice are statements to which the answer is either true or false, like the one on the previous page that says, “penguin is taller than.” We want to know whether the penguin is taller than the normalGuy. It’s almost impossible to tell just by looking at them, because their heights are so close together. So we will use a function to know for sure.

Step 2: cont. Since we only want the penguin to say “Hah! I’m taller” IF he is taller, we need to use something called an If Else statement. It is located below your method editor: First drag a Do in order into your method editor. Then, inside that, drag in an If Else statement.

normalGuy. person person

Step 2: cont. So let’s construct our command. Click on penguin in the object tree and then click on functions. Find the penguin is taller than function, and drag it over the word true in your If Else statement. When the little menu pops up, click on normalGuy. Your code will look like this:

Step 2: cont. Now click on penguin in the object tree, and then click on methods. Find penguin say, and drag it into the method editor under If. When the menu pops up, click on other, and type in “Hah! I’m taller!”. Your code will look like this:

Step 2: Now click on normalGuy in the object tree, and click on methods. Find normalGuy say and put under the Else part of your If Else statement. Tell him to say “Hah! I’m taller!” Your code will look like this: Now play your world. Who is taller, the penguin or the person?

Step 3: Using Number Functions First we’ll tell the man to say something. He’s tired of competing with the penguin about their height, and he wants to be friends. Click on normalGuy in the object tree, then click on methods. Find normalGuy say, and drag it under your If Else statement. Make him say “Let’s be friends. Give me a hug, penguin!” Your code will look like this: Now we’re going to use one of the functions that is a question whose answer is a number. We’re going to make the penguin move right up to the man and give him a hug. The only problem is, we don’t know how far to tell him to move! That’s why we’ll use a function!

Step 3: cont. Now we want the penguin to move right up to the guy to hug him. Click on penguin in your object tree and then click on methods. Find the penguin move and drag it into your method editor under everything else. We don’t know exactly how far yet, so just put 1 meter for now. Your code will look like this: Play your world just to see what it looks like.

Step 3: cont. Now we’re going to use a function to tell the penguin how far forward to move. Click on penguin in your object tree, and then click on the functions tab. Find the function called distance in front of. Drag that function over the 1 meter on your penguin move forward command and drop it there. On the menu that pops up, select normalGuy. Your code will look like this:

Step 4: Finishing Up The last thing you need to do is make the penguin hug the guy. Click on penguin in the object tree, and then click on the methods tab. Find the hug method and drag it into your method editor under everything else. Your final code will look like this: Now play your world and watch the magic!

Now you know the basic of using functions Now you know the basic of using functions. We only used two functions in this tutorial, but there are MANY functions in the Alice world that can be useful. Feel free to explore the uses of other functions.