Programming in Alice Chapter 2.

Slides:



Advertisements
Similar presentations
Mike Scott University of Texas at Austin
Advertisements

Space Man Sam: Grammar Mistakes By Aleis Murphy Duke University, Under the direction of Professor Susan Rodger July 2010.
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 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.
Introduction to Alice Alice is named in honor of Lewis Carroll’s Alice in Wonderland Modified by Serita Scott Further modified by Suzy Crowe.
Princess & Dragon Part 2: Teaching a Dragon to Fly—Methods & Properties By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Programming in Alice Chapter 2. Today’s Agenda Designing a Program Writing Methods Executing Instructions Simultaneously Comments Tips for Setting Up.
Creating an Animation Program Alice. Step 1: Design Decide on the problem to be solved Design a solution We will use a storyboard design technique, commonly.
Programming in Alice Chapter 2 Part 2. Events Editor Identifies what method is executed (run) when the “Play” button is hit 2.
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Implementation Algorithm  Code World.my first method Control blocks Statements (methods,
Animation Programs Alice. Overview 4-step process for creating animations Step 1: Understand Problem Step 2: Design Step 3: Implementation Step 4: Test.
Creating An Animation Program Alice Web Design Section 8-4.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running o Stored in.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Animation Programs: Scenarios and Storyboards Alice Web Design Section 8-3.
CS320n –Visual Programming Introduction to Alice Mike Scott (Slides 2)
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June
Events Chapter 7 Part 2. While a Key is Pressed Event Specialized event An event occurs when you press a key and continues until you take your finger.
Creating An Animation Program Part 2 Alice. Method A segment of program code (instructions) that defines how to perform a specific task.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition.
CS329e – Elements of Visual Programming Implementing Programs Mike Scott (Slides 2-2)
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.
By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
Alice Program Design and Implementation. Scenarios and storyboards The previous magician example illustrated a simple storyboard which depicts a scenario.
Lists Tutorial By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
Creating An Animation Program Alice. Step 1: Design Decide on the problem to be solved Design a solution We will use a storyboard design technique, commonly.
Storyboarding1 Steve Cooper Barb Ericson August 2009 Storyboarding.
Creating An Animation Program Alice. Recall We began the animation creation process We introduced the concept of storyboard We will continue using the.
Animation Programs: Scenarios and Storyboards
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1,
Animation Programs Alice.
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running Types of data.
Creating an Animation Program
Fall 2009ACS-1805 Ron McFadyen1 Chapter 2 Program Design & Implementation.
Storyboarding and Program Design Alice. Step 1: Design Decide on the problem to be solved Design a solution We will use a storyboard design technique,
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,
Fall 2007ACS-1805 Ron McFadyen1 Chapter 2 Creating Your First Animation (An Introduction to Programming)
Creating An Animation Program Alice. Recall from last lecture We began the animation creation process We introduced the concept of storyboard We will.
Animation Programs: Scenarios and Storyboards Alice.
Creating An Animation Program Alice. Recall We began the animation creation process We introduced the concept of storyboard We will continue using the.
Creating an Animation Program Alice. The programming steps.
An Introduction to Programming Using Alice 2.2, Second Edition Chapter 7 Recursive Algorithms.
Unit 2 Programming in Alice & Java 1. Day 1: Learning to Program  Objective: Understand the need for step-by-step logic; Basic working of a computer.
Creating an Animation Program Alice. Step 1: Design Decide on the problem to be solved Design a solution We will use a storyboard design technique, commonly.
Chapter 2: Programming in Alice
Beginning Animation. Storyboard An Invitation to Dinner 1.Marlin and Dory (two small fish) are swimming and talking. 2.A shark (Bruce) swims up behind.
Classes, Objects, and World-level Methods
An Introduction to Alice (Short Version)
Teaching Characters to Walk: Learning Methods, Part 1
Professor Susan Rodger
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
Introduction to Events
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Class-level Methods Alice.
Alice in Action with Java
Creating an Animation Program
Alice in Action with Java
Classes, Objects, and World-level Methods
Chapter 2: Programming in Alice
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.
Creating an Animation Program
Animation Programs: Scenarios and Storyboards
Lesson One: Objects in Alice: Positioning and Moving Them
Making Objects Move in Unison: Using Lists
Creating An Animation Program
Class-level Methods and Inheritance
Presentation transcript:

Programming in Alice Chapter 2

Today’s Agenda Designing a Program Writing Methods Executing Instructions Simultaneously Comments Tips for Setting Up an Initial Scene 2-2

Steps in Creating Programs Four step process What is problem? Design or plan ahead Implement or write the program Test to see if it works

Scenario Problem statement or story Also called requirement specifications In Alice consists of World scene Objects Actions

Scenario Provides Answers To What story is to be told? What objects are needed? Primary objects Background objects What actions are to take place? Become instructions in program

Scenario: First Encounter After traveling through space, a robot-manned craft just landed on a moon The robot sets up a camera so scientists in Houston can view this historic event The camera view shows the robot, lunar lander and nearby rocks An alien surprises the robot when it peeks out from behind a rock The robot sees the alien and walks over for a closer look The alien is frightened and hides behind rocks The robot calls Houston to report alien

Step 1: What is Problem? What story will be told? A robot’s first encounter with an alien on a distant moon What objects are used? Robot, lunar lander, alien, lunar background What actions take place? Alien peeks out from behind rock Robot turns head around & moves toward alien Alien hides behind rocks Robot sends message back to earth

Pseudo Code List of English worded steps to perform a task Provides algorithmic structure Breaks problem down into smaller tasks List all things that will be done in a scene You can also make basic drawing to better illustrate scene you wish to create Book refers to pseudo code Algorithm will be used in this class since it is a more familiar word and has similar meaning

Example Sketch For Scenario

Scenario Scene Not intended to be artistic Can use simple circles, squares and lines Label color of shapes Just give an idea of what scene will look like

Create Initial World Use Alice scene editor to add objects Arrange objects in various poses Capture screen as each successive scene is created for storyboard Active Learning: Students create initial world. Illustrate use of quad view to position objects relative to one another.

Algorithm for First Encounter Scenario Do following steps in order Alien moves up Alien says "Slithy toves?" Robot's head turns around Entire Robot turns to look at alien Do together Robot moves toward alien Robot legs walk Alien moves down Robot turns to look at camera Robot’s head turns red to signal danger Robot says “Houston, we have a problem!”

Step 3: Algorithm Implementation Translate algorithm steps into program Program A list of instructions to have objects perform animation actions from algorithm When programming you need to be concerned with Syntax – statement structure and punctuation Alice takes care of this for you You drag instruction to method editor Semantics – meaning of statements Sequence – order of programming instructions

Translating the Design Some algorithm steps can be written as a single instruction Ex: robot turns to face alien Other steps are composite actions that require more than one instruction To make the robot legs walk you need more than one instruction to cause multiple legs to move forward and bend at a joint

Writing Methods What is a method? Method Editor Set of instructions Create methods by dragging tiles from details pane into the Method Editor These tiles are the instructions Method Editor not available in Scene Editor mode my first method Method Editor

Dragging Method Tile to Editor To place instruction in method editor drag from details pane Pop-up menu appears asking for direction, select one Pop-up menu then asks for amount of distance to move Example: move instruction Arguments used in example Distance amount (use predefined values or other (enter value with keyboard)) Direction Drag method to editor

Method with Instruction Tiles Methods execute the instructions (tiles) that are dragged into the Method Editor

Terminology argument argument object method name editing tag Calling a method - executing a method Parameter – tells method more information on what to do Argument – information sent to method For method hare.move what direction to move? Possibilities for direction parameter are up, down, left, right How far to move is another argument to send move method Passing arguments A method is called with arguments sent to its parameters argument argument object method name editing tag

Entering Custom Number When other is chosen A number pad pops up Can enter number with keyboard Click on number pad Does not always work Click Okay or Cancel when done ‘/’ is for fractions instead of manually calculating it

Editing Tag Holds optional arguments What appears depends on the method Ex: Duration - amount of time for action to take place Default - 1 second

Duration Argument Each instruction takes 1 second to execute by default Can change time with duration option Increase or decrease duration for realism Increase to show movement over long distance and time Decrease to speed up action Synchronize objects together Example: Make leg move in sync with lunar robot Lunar robot moved 1 sec at time Each leg needed to move forward and backward in 1 sec Therefore move forward ½ sec and backward ½ sec

Style Argument Specifies how smoothly one movement will blend into next movement Gently – begins and end gradually Abruptly – begins and ends instantly Sometimes needed for smooth transition since gently shows what appears to be an abrupt end and beginning Begin gently – begins gradually, ends instantly End gently – begins instantly, ends gradually

Instructions (Methods) Methods available to use are: Move – forward, backward, up, down, left, right In meters Turn – left, right, forward, backward (revolutions) Roll – left, right (revolutions) Resize – increase or decrease size Say – put thought bubble over object Turn to face – select who to turn to face

dot notation: hare.move Primitive Methods All objects have common set of built-in methods for performing actions These “primitive methods” get objects to move, turn, change size, etc Seen in methods tab of details pane See list in Table 2-1 (pp. 65-66) with explanation of each one dot notation: hare.move

Control Statements Determines the sequence instructions are executed Drag instruction to code editor Sequential Action Block Actions occur one after another Simultaneous Action Block Actions occur at same time Drag block into editor Do in order

Do in Order By default, instructions are executed one after the other in the order they appear in the Method Editor It is best to place instructions in “Do in order” block Will be easier to move group of instructions if needed later 2-26

Do Together For simultaneous actions, drag “Do together” into the Method Editor Place instructions to be executed simultaneously in “Do together” block Make sure the duration for all items in “Do together” are same Otherwise some will finish quicker than others 2-27

Nesting Sometimes two groups of instructions need to be executed simultaneously Done by placing a “Do in order” block within a “Do together” block Example has brother penguin turn head right and left at same time as sister penguin does If head was turned left and right together nothing would happen Head would turn right and left at exact same time

Create Program Choose which sequence to execute instructions At same time Consecutively Refer to algorithm to find instruction order

FirstEncounter Program Traditional Lecture: Create the example world, line by line Active Learning: Create a part of the example world and allow students to complete the program.

Demonstrate Program Demonstrate creating FirstEncounter Traditional: Add comments as desired Active Learning: Add a comment and have students add another

Step 4: Testing Important step in creating a program is to run it To be sure it does what you expect it to do Use an incremental development process Write a few lines of code then run it Write a few more lines and run it Allows finding many problems and fix them as you go Called debugging – find bugs or errors in program

Comments Make the code understandable Not all combination of instructions are immediately obvious Explains purpose of segment of program to human reader Helps You read program later Others when determining what program does Alice ignores comments when executing program

Comment Example Comment //comment tile

Tips for Setting Up Initial Scene Can set initial position of objects in scene by Using mouse mode buttons from chapter 1 Right clicking object in object tree and move mouse of methods

Moving Object to Center of World Use move to method and choose entire world as method’s argument Places object’s center point at world’s center point of (0, 0, 0) This drives hare’s lower body into ground Center of gravity of hare is in abdomen Useful when lose object in scene or to set starting point 36

Positioning Character’s Arms

Tips for Setting Up Initial Scene Positioning objects a specified distance apart Ex: position teapot’s center point ½ meter to right of plate’s center point Move teapot object so its center point is same as plate’s center point Set pointOfView in properties of both objects world’s center point of (0, 0, 0) Use move method by right clicking on teapot then method then choose direction of right then ½ meter under amount 38

Moving Camera To An Object Right-click the object and choose Camera get a good look at this Camera moves to a position so the object is in plain view 39

Homework Read chapter 2 Do tutorials Tutorials 2-1, p 62 Tutorials 2-2, p. 67 Tutorials 2-3, p. 82 Tutorials 2-4, p. 89 Tutorials 2-5, p. 98 Do lab assignments Due one week after it is assigned