Lesson 7B Creating Our Own Methods Slides are adapted from aliceprogramming.net or

Slides:



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

Events in Alice By Henry Qin, edited by Jenna Hayes under the direction of Professor Susan Rodger Duke University, August 2008.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011.
Lesson 7 C Creating a New World Method— the Dragon Captures the Princess Slides are adapted from aliceprogramming.net or
Alice Learning to program: Part Four Creating Sounds, Making Billboards, Fun with 3-D Text, New Events, and Rotating Objects by Ruthie Tucker and Jenna.
Princess & Dragon – Version 2 By Michael Hoyle under the direction of Professor Susan Rodger Duke University July 2012 Part 2: Using Methods.
Princess & Dragon – Version 2 By Michael Hoyle under the direction of Professor Susan Rodger Duke University July 2012 Part 3: Billboards, Events, Sounds,
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
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.
Skater World: Part Four By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 2009.
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.
Alice Learning to program: Part Two by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Princess & Dragon Part 4: Breathing Fire—Adding Effects to Alice By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June.
1 Quiz Template: Click on the match By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 2009.
Checking for Collisions Ellen Yuan Under the direction of Professor Susan Rodger at Duke University June 2014.
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.
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.
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
Beowulf Battles Scene Dinah Poteat Duke University, Adventures in Alice, July 2013.
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
Alice Learning to program: Part Three Camera Control, Invisibility, and 3-D Text By Ruthie Tucker and Jenna Hayes, Under the direction of Professor Rodger.
Playing Music in Alice By David Yan Under the direction of Professor Susan Rodger July 2015.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
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.
Animating Objects in Groups: Using Arrays and Lists By Ruthie Tucker under the direction of Professor Susan Rodger Summer 2008.
CompSci 4 Fall 2010 Classwork 2 – Princess and Dragon World By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
Playing Music in Alice By David Yan Under the direction of Professor Susan Rodger July 2015.
Princess & Dragon Part 1: Objects in an Alice World By Elizabeth Liang under the direction of Professor Susan Rodger Duke University May 2010.
Lesson 9B Adding sound and Billboards. What is a function? Give an example. How do you create a method? Give an example. What is an event? Give examples.
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
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1,
What are Buttons? Buttons can be clipart, pictures or animated gifs When you click on buttons they can send you to another slide Buttons can be used to.
Alice Workshop November 2009 By: Kim Glavan New Lenox School Dist #122.
Buttons and Birds: Introduction to Interactive Events in Alice By Henry Qin, edited by Jenna Hayes under the direction of Professor Susan Rodger Duke University,
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.
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.
Skater World: Part Four By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1, 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.
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.
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.
Professor Susan Rodger
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
Changing Color, Using Text Objects, and Random Selection in Alice
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
Getting Started With Alice
Tutorial for Arrays and Lists
under the direction of Professor Susan Rodger
Restricting Events Creating Conditional Events in Alice By Henry Qin
Presentation transcript:

Lesson 7B Creating Our Own Methods Slides are adapted from aliceprogramming.net or

Creating New Methods We create new methods that put together the simple methods Alice gives us for each object in order to create short animations that we can use over and over. We’ll use this to teach the dragon to fly.

Click on dragon in the object tree and in the methods pane, click create new method. Name it fly and select OK. DragonFly Object Method

You will see a new tab pop up in the method editor labeled dragon.fly and also a new method called fly in the dragon’s methods.

Step 2: Tabs There are now two tabs in the method editor. Each tab represents a different method and the code for that method. Click on world.my first method and you will see the code that we wrote before. Click on the dragon.fly tab and you will see there is no code. The code that we will put in here will teach the dragon to fly. CAUTION: When you have multiple tabs, always make sure the correct tab is up before dragging and dropping in code.

First drag in a Do together then a Do in order inside and another Do together. These blocks set up the method that we will fill in. There are two types of methods you can create, object level methods and world level methods. We have created an object level method because the method is inside the object dragon. In an object level method, all the animations must stay within the object and not use any other objects in the world.

Click on the + next to the dragon in the object tree and scroll down until you find the rightWing which we will animate. Since this is an object method in the object dragon, we will only use objects that are part of the dragon. The dragon has a lot of parts but we will focus on his wings which are further divided into flaps. Note: Your dragon may have a rightWingClose instead of rightWing depending on your version of the Alice object. These are the same but with different names. Use rightWingClose instead of rightWing and instead of flap use rightWingFar.

Drag in a roll command from the rightWing’s list of methods into the second Do together. Select right, other, and punch in.15.

2. Drag in the flap roll method into the Do together, select left, other. Punch in Click on the + next to the dragon’s rightWing in the object tree and then click on flap. 3. Drag in the flap turn method into the Do together, select right and then ¼ revolution.

We need to make a copy and do the reverse so drag the Do together block onto the clipboard.

Drag the block of code from the clipboard underneath the Do together inside the Do in order block. Reverse the directions from right to left and left to right on each line.

Press Play. When you try to test the method we’ve been writing a warning box will pop up. In Alice there has to be a starting point for running your code. In the event editor, you can see When the world starts, do world.my first method. The default is to run the code in the first method you wrote, my first method. For testing purposes, we can change the method that is run. In this case we would like to test out the dragon.fly method to make sure it works before we integrate it into the program

In the event editor, change the method that plays When the world starts to dragon fly. Now press play and you will see the dragon’s right wing flap once. Let’s repeat for the left wing!

Copy the entire Do in order block onto the clip board Drag from the clipboard into the big Do together, underneath the previous Do in order.

Change all the rightWing references to leftWing by clicking each of the lines next to dragon.rightWing. Select dragon, leftWing, the entire leftWing. Do the same for the flap references.

Step 2: Animation Continued Flip the order of the two Do together blocks by dragging the second one above the first one. This is what it should look like when you’re done. Go to the next slide to see the final code for the method.

This is the final code for dragon.fly

Press play to see the dragon flap his wings!