Parameters and World-level methods Alice. Our Dragon world The dragon must to take off and fly, to carry the princess.

Slides:



Advertisements
Similar presentations
Lesson 7 C Creating a New World Method— the Dragon Captures the Princess Slides are adapted from aliceprogramming.net or
Advertisements

CS320n –Visual Programming Class-level Methods and Inheritance – Part 1 Mike Scott (Slides 4-3-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger.
Class-level Methods Alice. World / Class Method World method A general method that may refer to multiple objects; not closely associated with any particular.
Class-level Methods and Inheritance Part 1 Alice.
Class-level Methods Chapter 6. Class-level Method Is specific to a class of objects We can give a class new abilities/methods Only involves this one class.
Review of Chapter 4 Sections 1 and 2 World-level methods involve two or more objects break a large problem into smaller, logical units follow a design.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Class-level Methods and Inheritance MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
Alice and Media Computation August 2009 Animation Storyboard  Code Steve Cooper Barbara Ericson.
CSC1401 Animation Creating methods/instructions (class-level)
Princess & Dragon Part 2: Teaching a Dragon to Fly—Methods & Properties By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
Alice Methods and Classes. Methods and Classes Methods – Coordinated sequence of instructions carried out when requested (e.g. move, turn to, etc.) Class.
Lesson 7B Creating Our Own Methods Slides are adapted from aliceprogramming.net or
World-level Methods with Parameters Alice. Larger Programs As you become more skilled in writing programs, you will find that your programs quickly begin.
Parameters Alice.
Parameters Section 8-8 Web Design. Objectives The student will: Understand what a parameter is Understand how to use a parameter in Alice Understand how.
Fall 2009ACS-1805 Ron McFadyen1 Functions A function is a collection of statement, similar to a method, but a function is defined to return a value to.
CS320n –Visual Programming Random Numbers and Random Motion (Slides 6-3) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Fall 2007ACS-1805 Ron McFadyen1 Functions and if-else A function is a collection of statement, similar to a method, but a function is defined to return.
Tips & Techniques 6 Random Numbers and Random Motion Alice.
Classes, Objects, and World-level Methods Alice. Programming in Alice© 2006 Dr. Tim Margush2 Class / Object Class A template describing the characteristics.
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.
Functions and Conditionals in Alice 1 Stephen Cooper Wanda Dann Barb Ericson September 2009.
Classes, Objects, and World-level Methods
Today’s Agenda 1.Collect Pre-Lab 4 2.Alice Programming Assignment Storyboards 3.Classes 4.Objects 5.Methods 6.Assign pair programming teams and meet upstairs.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
Classes, Objects, and World-level Methods Section 47 Web Design.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
Class-level Methods Chapter 6 part 1. Classes and Objects Classes o In Alice, classes are predefined as 3D models Objects o An object is an instance of.
Today’s Agenda 1.Collect Pre-Lab 5 2.Collect Alice project storyboards 3.Events 4.Dummy Objects 5.Assign pair programming teams and meet upstairs for Lab.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Parameters and Event-Handler Methods Alice. Mouse clicks Interactive programs often allow the user to mouse click an object in the display. buttons in.
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.
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.
Writing Our Own Functions Alice. Functionality A function receives value(s), performs some computation on the value(s), and returns (sends back) a value.
What we will do today Learn about functions in Alice.
Functions Alice.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
Programming: Simple Control Structures Part 2 – Repetition Alice.
Creating and Calling Procedures Alice 3 Beta. A few choices to be made Right window, upper left hand corner start by clicking on Class “MyScene” button.
Alice Workshop November 2009 By: Kim Glavan New Lenox School Dist #122.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running Types of data.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Classes, Objects, and World-level Methods MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
Functions Sec 8-11 Web Design. Objectives The Student will: Understand what a function is Know the difference between a method and a function Be able.
Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Functions, Loops, and Parameters.
Questions Alice. Functionality A question receives value(s), performs some computation on the value(s), and returns (sends back) a value.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
World-level Classes Chapter 6 Part 2. Programs Grow Program code grows larger over time This makes it more difficult to read and process the code in our.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Parameters Alice. A beetle band Our task is to create an animation for a bug band as an advertisement for their next concert.
Parameters Alice. Overview The need for more flexible methods Passing a parameter to a method Demos Using the Alice interface to write code for a parameter.
Parameters MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum redesign project funded.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Using Placeholders to Simplify your Methods: Learning Methods, Part 2 By Deborah Nelson Duke University Professor Susan Rodger June 16, 2008.
Alice in Action with Java Chapter 4 Flow Control.
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.
Tips & Techniques 6 Random Numbers and Random Motion Alice.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Parameters Section 8-8 Web Design.
Creating your Function
Parameters Alice.
Alice and Media Computation August 2009
Class-level Methods Alice.
Parameters and World-level methods
Princess & Dragon Part 2: Teaching a Dragon to Fly—Methods & Properties By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
Using Alice This is an introduction to Alice..
Parameters Alice.
Class-level Methods and Inheritance
Presentation transcript:

Parameters and World-level methods Alice

Our Dragon world The dragon must to take off and fly, to carry the princess

Storyboards We can make the dragon takeOff and fly. Dragon.takeOff Do together dragon move up 1 meter dragon flap its wings Dragon.fly Do together dragon move forward 1 meter dragon flap its wings Note that we would need very similar methods to get the dragon to land (by flying down) or to fly in other directions

A Better Solution Multiple versions of very similar code seems a bit tedious. The only things that change is the direction the dragon is to fly. A better solution is to write a more flexible method.

Parameters Built-in methods provide flexibility by providing parameters such as distance and direction. Parameters allow you to pass in values (arguments). Example Parameters: direction, distance, duration Arguments: left, 0.05 revolutions, 0.5 seconds

Kinds of Parameters Alice provides several kinds of parameters that can be used in your own methods.

The storyboard Dragon.flyInAnyDirection Parameter: whichDirection Do together dragon move in whichDirection dragon flap its wings In this example, we can write just one method and use a parameter to specify: which direction the dragon is to fly.

Demo Concepts illustrated Enter name and select the type of each parameter whichDirection is a Direction parameter A parameter acts as a placeholder in the instruction Arguments are passed to the parameter in the call to the method

A Number parameter Add a Number parameter to specify the distance the dragon travels as it is flying. Note that the call to the method must now include an argument for the distance.

World-level methods It is also possible to create world-level methods These are used when there are references to multiple objects in the world

Example Consider our dragon world The dragon has taken off Now it must fly to the princess. Such a method will involve 2 objects: the dragon and the princess

Demo: Starting a new method First, to associate the new method with the World select the World tile in the Object Tree select the methods tab in the details area click on the "create new method" button