Methods (part 2) Alice In Action, Ch 2

Similar documents
Methods (part b) Alice In Ac5on, Ch 2

Methods (part 1) Alice In Action, Ch 2

potions. The troll doubles in size.

Events (Alice In Action, Ch 6)

Events (Alice In Ac.on, Ch 6)

The Alice Scene Editor

Introduction to Events

Flow Control: boolean expressions, if selec5on statements (Alice In Ac5on, Ch 4)

Welcome to CS120 Fall 2012

Chapter 0. Getting Started. Objectives

Chapter 2 Motion. Now consider a horizontal pipe running through it (left to right). Now, a vertical pipe (top to bottom) runs through the same point.

Alice: A Free 3D Animation World for Teaching Programming

3D Transformations. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 11

Getting Started with Java Using Alice. 1 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

3D Transformations. CS 4620 Lecture 10. Cornell CS4620 Fall 2014 Lecture Steve Marschner (with previous instructors James/Bala)

Geometric Transformations

Alice. Coverage. Mathematical Expressions, Conditional Statements, Control Structures. Arithmetic Expressions Built-in Functions Conditional Execution

An object in 3D space

Help Topics. Help Topics. Preferences. Acrobat Tool Bar. Search. Bookmarks. Printing Support

Alice 3 Workshop. CS & IT Irvine, CA July 9, Copyright 2012 Wanda Dann, Don Slater, Steve Cooper

Alice. Creating Sounds, Making Billboards, Fun with 3 D Text, New Events, and Rotating Objects

Animate a Name Cards

ICS 61 Game Systems and Design Introduction to Scratch

Duration 30 minutes Notes This tutorial was built using Alice

CodeHS Hour of Code: Teacher Guide

Scratch Lesson 2: Movies Made From Scratch Lesson Framework

Scene Modeling for a Single View

Methods & Classes in Alice

Week Lesson Assignment SD Technology Standards. Knowledge Check. Project Project Project Power Point 3.1. Power Point 3.

Alice Methods and Classes. Methods and Classes

Excel Boot Camp PIONEER TRAINING, INC.

CIS 580, Machine Perception, Spring 2015 Homework 1 Due: :59AM

2. Click on the Launch button and select Terminal. A window will appear which looks like:

Lecture 22 of 41. Animation 2 of 3: Rotations, Quaternions Dynamics & Kinematics

Lecture 22 of 41. Animation 2 of 3: Rotations, Quaternions Dynamics & Kinematics

Geometric transformations in 3D and coordinate frames. Computer Graphics CSE 167 Lecture 3

Scene Modeling for a Single View

Lego Club week one Wonderland to Oxford Bridge over river Isis : Thursdays 4-5pm Worple School pick up 3.30pm

Vision Review: Image Formation. Course web page:

Introduction to Alice. Computer Science for High School (CS4HS)

Plotting Points. By Francine Wolfe Professor Susan Rodger Duke University June 2010

Detailed instructions for video analysis using Logger Pro.

Extrusion Revolve. ENGR 1182 SolidWorks 02

AGB 260: Agribusiness Data Literacy. Excel Basics

CompSci 94 Classwork: While loops and Randomness March 6, Prof. Susan Rodger CompSci 94 Spring 2018

CS Problem Solving and Object-Oriented Programming

Autodesk Navisworks Freedom Quick Reference Guide

Table of contents. I Preface. II First steps 1. 3D stage 2. Your first stage

IM 8 Ch How Can I Move A Shape On A Grid (continued) November 15, 2014

Repetition everywhere comparing while in a method and as an event. Comparison

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

Ceilbot vision and mapping system

Lecture 6: Scatter Plots and R Skills

6.1.3 How can I describe it?

animation, and what interface elements the Flash editor contains to help you create and control your animation.

User manual Horus Movie Player 1

Visual Physics - Introductory Lab Lab 0

Mac OS X Part 3. The University of Utah Student Computing Labs Macintosh Support

Assignment 1 due 4/13/2017 at 11:59PM Topic: Getting Started with WebGL and Transformations

Interactive Computer Graphics

Windows Movie Maker / Microsoft Photo Story Digital Video

Tangents. In this tutorial we are going to take a look at how tangents can affect an animation.

PC4G - University of Waterloo December 8, 2017

Microsoft Office Excel 2010: Basic. Course Overview. Course Length: 1 Day. Course Overview

3D Capture. 3D Capture. 3D Capture. 3D Capture. Real-world

SimLab 3D PDF Settings. 3D PDF Settings

Animating the Page IN THIS CHAPTER. Timelines and Frames

Computer Graphics: Viewing in 3-D. Course Website:

Tutorial00. Jumping down the rabbit hole

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

Is there a different way to get the same result? Did we give enough information? How can we describe the position? CPM Materials modified by Mr.

How to Give Credit for Completed Items & Scheduled Offerings

Finding your Pictures

Visual Physics Introductory Lab [Lab 0]

COMP : Practical 6 Buttons and First Script Instructions

1. Textbook #1: Our Digital World (ODW). 2. Textbook #2: Guidelines for Office 2013 (GFO). 3. SNAP: Assessment Software

Classes, Objects, and World-level Methods. Alice

Homework 09. Collecting Beepers

CS4620/5620. Professor: Kavita Bala. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

Managing Content with AutoCAD DesignCenter

Microsoft Office Excel 2007: Basic. Course Overview. Course Length: 1 Day. Course Overview

Lec 10 MEL for Dynamics

Class-level Methods. Chapter 6 part 1

BONE CONTROLLER ASSET VERSION 0.1 REV 1

5. Canvas overview. Cricut Design Space User Manual. Design Panel

Editing and Finishing in DaVinci Resolve 12

Screenplay. Timing and motion. Martin Constable October 23, RMIT Vietnam

ME scopeves 5.0. Reference Manual. Volume IIA Basic Operations. (August 2008)

Math background. 2D Geometric Transformations. Implicit representations. Explicit representations. Read: CS 4620 Lecture 6

Lab 1-Digital & Physical Models

Sphero Lightning Lab Cheat Sheet

Sorting Fields Changing the Values Line Charts Scatter Graphs Charts Showing Frequency Pie Charts Bar Charts...

Adobe Premiere Pro CC 2015 Tutorial

8.4 Organizing Data In Excel. MDM - Term 3 Statistics

Creating Classroom Websites Using Contribute By Macromedia

DEPARTMENT OF BUSINESS AND OFFICE ADMINISTRATION COURSE OUTLINE FALL 2017 OA 1145 B2 3( ) Excel and Access, Core 67.5 Hours

Scene 2, Flash. STEP THREE: Same with the mouths, if you have it touching the ears or something, move it so there is clearance.

Methods in Alice. Brookwood High School Mrs. Crystal L. Furman

The Environment. Scratch Programming. The Environment. The Environment. The Environment. The Environment. Lesson 1: Introduction THE STAGE

PICTURES FOR BEGINNERS MANUAL

Transcription:

CS 120 Lecture 03 Methods (part 2) Alice In Action, Ch 2 4 September 2012 Slides Credit: Joel Adams, Alice in Action Objectives Build class-level methods to elicit desirable behaviors from objects Reuse a class-level method in multiple worlds Understand how an object s position, orientation, and point of view are described, changed and determined Documenting your code with comments. Understand Flow of Control with methods. 2 1

Methods Methods behavior-producing messages (from the sender s view) behaviors/actions in response to requests, messages (from the recipient s view) E.g. in world.my_first_method: whiterabbit.pointat(camera) Convention for naming methods Name should be a verb or verb phrase Name should describe what the method does A method is a way to name a block of code. 3 Methods Objects have predefined methods for common tasks Methods may also be created by Alice developers Two main reasons for building your own methods To provide an object with additional behaviors (Today) To organize your story and program into more manageable pieces (last Tuesday) Divide and conquer methodology Break a big problem into smaller problems Solve each of the smaller problems Combine the solutions of smaller problems into a solution for the original, big problem Hiding complex details with abstraction. Alice in Action with Java 4 2

World Methods for Scenes and Shots User stories can be divided into scenes and shots Scene: segment of a story, usually set in one location Shot: part of a scene, normally from one fixed camera view Use multiple scenes and shots to create a program that reflects the user story and has a modular design Two shots of one scene 5 World and Object Methods World method: affects behavior of all objects in a world Object method: defines behavior for a single object (that may have multiple parts) examples: flapwings()for dragon, hop() for a rabbit Alice in Action with Java 6 3

Program Documentation Standalone readme, manual Comments: explanatory remark ignored by Alice an integral part of code Used to describe what code does at various levels the overall program, individual methods, blocks of statements. Useful for collaborators and developers themselves Important part of programming Also a component evaluated for your program grades Alice in Action with Java 7 Object Methods for Object Behaviors Example 1: Hiding complex details Add a EvilStepsister1 object to the world Select evilstepsister1 from object tree and click methods tab Click create new method and enter melt Make her melt (she s a witch!!): Send messages to evilstepsister1 Set opacity to 0 Resize her Say something Invoke melt() from my_first_method() Add comments to the melt() method 8 4

Thinking in 3D Learn about 3D movement to work in Alice Object s position determines object s location in the 3D world is changed an object s translational motion Object s orientation determines the way an object is facing is changed by an object s rotational motion 9 3 Dimensions, 6 Degrees of Freedom A 3D object has 3 dimensions in the directions of height, width, depth 6 degrees of freedom Pose: 3 positions, 3 orientations Motion: 3 translations, 3 rotations 5

An Object s Position Three axes are used to define the world space LEFT-RIGHT (LR): world s width dimension UP-DOWN (UD): world s height dimension FORWARD-BACKWARD (FB): world s depth Three values specify object center s position in the world: lr, up, fb 11 Center of an object At the center of mass Where it stands on the ground Where it is held 6

An Object s Position The position of the center of an object, i.e. its lr, up and fb values, are with respect to the world s axes Change an object s position using move() Directional values (up, down ) are with respect to object s axes 13 An Object s Orientation The orientation of an object, i.e. its yaw, pitch and roll values, are with respect to the world s axes Change an object s position using turn(),roll() Directional values (left, right, ) are with respect to object s axes Alice in Action with Java 14 7

An Object's Rotational Motion Again: rotational motion are specified w.r.t. object s own axes Yaw: amount of object s rotation about the UD-axis Example: shaking head for no, turn(right, ) Pitch: amount of object s rotation about the LR-axis Example: nodding head for yes, turn(forward, ) Roll: amount of object s rotation about the FB-axis Example: roll(left, 0.25) Alice in Action with Java 15 An Object's Orientation (continued) Alice in Action with Java 16 8

An Object's Orientation (continued) e.g. from the current orientation, turn(forward, 0.25): nose down turn(backword,0.25): nose up 17 An Object's Orientation (continued) 18 9

Point of View Combines object s position and orientation Six values in point of view: [(lr, ud, fb),(yaw, pitch, roll)] Six values correspond to six degrees of freedom Methods used to change six values move(), turn(), and roll() Method used to change point of view setpointofview() 19 Six Degrees of Freedom (6 DOF) http://en.wikipedia.org/wiki/six_degrees_of_freedom 20 10

Object Methods for Object Behaviors Example 2: Telling a Dragon to Flap its Wings Add a dragon object to the world Select dragon from object tree and click methods tab Click create new method and enter flapwings Send roll() messages to each of the dragon s wings Invoke flapwings() from my_first_method() Add comments to the flapwings() method Alice in Action with Java 21 Object Methods for Object Behaviors (continued) Alice in Action with Java 22 11

Object Methods for Object Behaviors (continued) Alice in Action with Java 23 Object Methods for Object Behaviors (continued) Example 3: Telling a Toy Soldier to March Four actions correspond to four steps for march() 1 marchleft; 2 marchright; 3 marchright; 4 marchleft. Define marchleft() and marchright() methods These methods produce reverse behaviors Incorporate new methods into march() Call march()four times from my_first_method() Alice in Action with Java 24 12

Object Methods for Object Behaviors (continued) Alice in Action with Java 25 Object Methods for Object Behaviors (continued) Alice in Action with Java 26 13

Alice Tip: Reusing Your Work Copy and past techniques speed up development How to use make copy to duplicate statements Right-click bar in editing area containing method Select make copy Example using make copy Refer to my_first_method() in Toy Soldier program Copy three march() statements from first march() Alice in Action with Java 27 Alice Tip: Reusing Your Work (continued) Alice in Action with Java 28 14

Using the Clipboard Alice clipboard Used to copy and paste all statement types Located in the events area Using Alice clipboard in Toy Soldier program Drag doinorder in my_first_method() to clipboard Create scene1() method Drag statement in clipboard to editing area Drop statement in the scene1() method Only one statement may be placed in the clipboard You can increase the number of available clipboards Alice in Action with Java 29 Using the Clipboard (continued) Alice in Action with Java 30 15

Using the Clipboard (continued) Alice in Action with Java 31 Reusing an Object in a Different World Alice lets you reuse objects in different worlds Reusing operation involves save and import tasks How to save the dragon object Rename the dragon object flappingdragon Right-click flappingdragon, select save object Navigate to appropriate storage location in the directory Click the Save button How to import an object into a new world Open new world and choose Import from File menu Navigate to object location and select.a2c file Alice in Action with Java 32 16

Reusing an Object in a Different World (continued) Alice in Action with Java 33 Reusing an Object in a Different World (continued) Alice in Action with Java 34 17

Summary Divide and conquer approach: decomposing a user story into scenes and shots Define methods to support modular design and provide advanced operations World methods: messages sent to the world Object methods: define behaviors for a single object Comments: remarks that explain program statements Flow of Control: How methods modify sequential execution. 35 Summary (continued) Alice clipboard: stores a copy of any statement An 3D object has six degrees of freedom Object s position: lr, up, fb Object s orientation: yaw, pitch, and roll Consider the many reasons to create a method. 36 18

Readings: Student To Do s Alice in Action, Chapter 2 Practice on your own: Lab 1 to be posted on website. Homework: 1) Recreate a movie scene or create your own short story. 2) Create your own Scene 1 and 3 for the Wizard vs. Trolls program. For both problems: Use world methods to break the stories up into shots. Move the camera around. Comment your program. Demo your Alice HW in Lab on Monday (Bring it with you!) 37 19