csci 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 methods for scenes (continued) how...
TRANSCRIPT
![Page 1: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/1.jpg)
CSCI 1111Introduction to Software Development
Rhys Price Jones
Week 2Methods
based on Joel Adams
Friday, September 2, 2011
![Page 2: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/2.jpg)
2
WEEK 2 OBJECTIVES
Build world-level methods to help organize a story into scenes and shots
Build class-level methods to elicit desirable behaviors from objects
Reuse a class-level method in multiple worlds
Use dummies to reposition the camera for different shots within a scene
Understand how an object’s position, orientation, and point of view are determined
Friday, September 2, 2011
![Page 3: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/3.jpg)
3
METHODS
Method: behavior-producing message
Objects have predefined methods for basic tasks
Methods may also be created by Alice developers
Friday, September 2, 2011
![Page 4: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/4.jpg)
4
OBJECT METHODS - EXAMPLE
Add a pterodactyl to the world
local-gallery > animals > pterodactyl
click to placethen move to desired position
use methods to set size, position, etc.
Look at the available methods
This pterodactyl cannot flap its wings
Friday, September 2, 2011
![Page 5: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/5.jpg)
MISSING A CRUCIAL OBJECT METHOD!
Object method: defines behavior for a single object
Illustration: we would like to send flapWings() to a pterodactyl
Friday, September 2, 2011
![Page 6: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/6.jpg)
TELLING PTERODACTYL TO FLAP WINGS
Select pterodactyl from object tree and click methods tab
Click create new method and enter flapWings
Send roll() messages to each of the dragon’s wingsInvoke flapWings() from my_first_method()
Add comments to the flapWings() method
Friday, September 2, 2011
![Page 7: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/7.jpg)
7
Book does dragon -- not pterodactyl
Friday, September 2, 2011
![Page 8: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/8.jpg)
8
Adding comments
Friday, September 2, 2011
![Page 9: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/9.jpg)
TWO REASONS FOR BUILDING METHODS
To provide an object with additional behaviors: Object methods
To organize your story into more manageable pieces: World methods
Friday, September 2, 2011
![Page 10: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/10.jpg)
10
WORLD METHODS FOR SCENES AND SHOTS
Scene: segment of a story
Shot: part of a scene from a given camera position
User stories can be divided into scenes and shots
A convenient technique for completing a project
Divide and conquer approach to building user stories
Break a big problem into smaller problems
Solve each of the smaller problems
Combine the smaller problems into a solution
Friday, September 2, 2011
![Page 11: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/11.jpg)
11
METHODS FOR SCENES
Scenario: develop a user story with three scenes
Convention for naming methods
Name should be a verb or verb phrase
Name should describe what the method does
Creating the first new method
Select the world object
Click the create new method in the details area
Enter playScene1 in the New Method dialog box
Check new method by sending say() to ground
First test fails because my_first_method() is empty
Friday, September 2, 2011
![Page 12: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/12.jpg)
12
Methods for Scenes (continued)
Friday, September 2, 2011
![Page 13: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/13.jpg)
13
Methods for Scenes (continued)
Friday, September 2, 2011
![Page 14: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/14.jpg)
14
METHODS FOR SCENES (CONTINUED)
How to fix the first bug
Click on the tab for my_first_method
Drag a doInOrder control to the top of the pane
Click on world in the object tree
Drag playScene1() into the doInOrder statement
Extend technique used to build playScene1()
Add two methods: playScene2(), playScene3()
New method sends a say() message to the ground
New Methods are called in my_first_method()
Friday, September 2, 2011
![Page 15: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/15.jpg)
15
Methods for Scenes (continued)
Friday, September 2, 2011
![Page 16: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/16.jpg)
16
Methods for Scenes (continued)
Friday, September 2, 2011
![Page 17: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/17.jpg)
17
METHODS FOR SHOTS
Scenes can be divided into shots
Shots can be further divided into pieces
Reasons for using scenes, shots, and pieces
To create a program that reflects the user story
To create a program that has a modular design
Example of a scheme using scenes and shots
Level 1: my_first_method()
Level 2: three methods for three scenes
Level 3: four methods for four shots in Scene 2
Friday, September 2, 2011
![Page 18: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/18.jpg)
18
METHODS FOR SHOTS (CONTINUED)
Implementing the scheme
Test each shot in Scene 2 using a say() method
Call the four shot methods from playScene2()
Call three scene methods from my_first_method()
Structure diagram reflects organization of user story
All objects added to world become part of world
Scene and shot messages are stored in the world
World method: affects behavior of multiple objects
Friday, September 2, 2011
![Page 19: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/19.jpg)
19
Methods for Shots (continued)
Friday, September 2, 2011
![Page 20: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/20.jpg)
20
Methods for Shots (continued)
Friday, September 2, 2011
![Page 21: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/21.jpg)
OPEN ALICE
open world week2/WorldMethods
add a scene 4
where the ground thinks this is all pretty dull!
Friday, September 2, 2011
![Page 22: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/22.jpg)
TWO REASONS FOR BUILDING METHODS
To provide an object with additional behaviors: Object methods
To organize your story into more manageable pieces: World methods
Back to Object Methods
Friday, September 2, 2011
![Page 23: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/23.jpg)
23
OBJECT METHODS EXAMPLE 2
Telling a Toy Soldier to March
Four actions correspond to four steps for march()•1 marchLeft;
•2 marchRight;
•3 marchRight;
•4 marchLeft.
Better names might be halfLeftStephalfRightStep
Friday, September 2, 2011
![Page 24: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/24.jpg)
DEFINE
marchLeft() and marchRight() methods
These methods produce reverse behaviors
Incorporate new methods into march()Call march()four times from my_first_method()
Friday, September 2, 2011
![Page 25: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/25.jpg)
25
The marchLeft() method
Friday, September 2, 2011
![Page 26: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/26.jpg)
26
The march() method
Friday, September 2, 2011
![Page 27: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/27.jpg)
27
ALICE TIP: REUSING YOUR WORK
Copy and paste 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()
Friday, September 2, 2011
![Page 28: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/28.jpg)
28
Alice Tip: Reusing Your Work (continued)
Friday, September 2, 2011
![Page 29: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/29.jpg)
29
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
Friday, September 2, 2011
![Page 30: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/30.jpg)
30
Using the Clipboard (continued)
Friday, September 2, 2011
![Page 31: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/31.jpg)
31
Using the Clipboard (continued)
Friday, September 2, 2011
![Page 32: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/32.jpg)
REUSING AN OBJECT
in a Different World
Alice lets you reuse objects in different worlds
Reusing operation involves save and import tasks
Friday, September 2, 2011
![Page 33: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/33.jpg)
SAVE THE PTERODACTYL OBJECT
Rename the pterodactyl object flappingPterodactyl
Right-click flappingPterodactyl, select save object…
Navigate to appropriate storage location
Click the Save button
saves as FlappingPterodactyl.a2c
note capitalization
Friday, September 2, 2011
![Page 34: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/34.jpg)
HOW TO IMPORT AN OBJECT
into a new world
Open new world and choose Import from File menu
Navigate to appropriate location and select the correct .a2c file
Friday, September 2, 2011
![Page 35: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/35.jpg)
35
Book’s dragon example
Friday, September 2, 2011
![Page 36: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/36.jpg)
36
Book’s dragon example
Friday, September 2, 2011
![Page 37: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/37.jpg)
QUIZLET
1. True or False: A method name should usually be a verb or verb phrase.
Answer:
2. A method that affects the behavior of multiple objects (like a scene) should be defined as a(n) ____________________ method.
Answer:
3. A(n) ____________________ method is used to define a complex behavior for a single object.
Answer:
4. True or False: Comments are ignored by Alice.
Answer:
Friday, September 2, 2011
![Page 38: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/38.jpg)
QUIZLET ANSWERS
1. True or False: A method name should usually be a verb or verb phrase.
Answer: True
2. A method that affects the behavior of multiple objects (like a scene) should be defined as a(n) ____________________ method.
Answer: world
3. A(n) ____________________ method is used to define a complex behavior for a single object.
Answer: object
4. True or False: Comments are ignored by Alice.
Answer: True
Friday, September 2, 2011
![Page 39: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/39.jpg)
39
ALICE TIP: USING DUMMIES
Review
Scenes comprise shots
Shots are filmed with the camera in a given positionAlice places a camera object in every world
Friday, September 2, 2011
![Page 40: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/40.jpg)
TWO TECHNIQUES FOR SHIFTING POSITION OF CAMERA
Use set of motion-related messages, such as move()
Use an invisible marker called a dummyDummy: invisible marker with a point of view
Dummies are used to change a camera’s position
Friday, September 2, 2011
![Page 41: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/41.jpg)
DESCRIPTION OF A SCENE
that will use dummies
Wizard intervenes to prevent trolls from taking a castle
Camera changes position for each of three shotsStory conforms to structure in Figure 2-11 (less Shot 4)
Friday, September 2, 2011
![Page 42: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/42.jpg)
SETTING UP THE FIRST SHOT OF SCENE 2
Add castle, wizard, and trolls to build the scene
Click more controls button and then drop a dummy
Go to object tree and rename dummy scene2Shot1
Friday, September 2, 2011
![Page 43: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/43.jpg)
43
Dummies (continued)
Friday, September 2, 2011
![Page 44: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/44.jpg)
44
Dummies (continued)
Friday, September 2, 2011
![Page 45: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/45.jpg)
SECOND SHOT OF SCENE 2
Using camera controls, zoom in on the wizard
Press the drop dummy at camera button
Rename the second dummy, scene2Shot2
Friday, September 2, 2011
![Page 46: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/46.jpg)
THIRD SHOT OF SCENE 3
First dummy will be reused for this shot
Friday, September 2, 2011
![Page 47: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/47.jpg)
47
Dummies (continued)
Friday, September 2, 2011
![Page 48: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/48.jpg)
48
USING SETPOINTOFVIEW()
to Control the Camera• obj.setPointOfView(obj2)
Changes the position of obj to obj2
Example: camera.setPointOfView(aDummy)
Friday, September 2, 2011
![Page 49: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/49.jpg)
CODE FOR
the first shot of Scene 2
Drag a doInOrder statement to the editing area
Click on camera object in the object tree
Drag setPointOfView()to the editing area
Select scene2Shot1 dummy as target and 0 duration
Add say() statements for each of the trolls
Add a comment to explain the purpose of the method
Friday, September 2, 2011
![Page 50: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/50.jpg)
50
Scene2Shot1
Friday, September 2, 2011
![Page 51: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/51.jpg)
51
Scene2Shot1
Friday, September 2, 2011
![Page 52: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/52.jpg)
CODE FOR
the second shot of Scene 2
Set the opacity of the wizard to 0 in properties pane
Drag wizard’s opacity property to editing area
Set the opacity to 1 in the set() method
Set the camera’s point of view to scene2Shot2
Add a say() statement for the wizard
Friday, September 2, 2011
![Page 53: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/53.jpg)
53
Scene2Shot2
Friday, September 2, 2011
![Page 54: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/54.jpg)
CODE FOR
the third shot of Scene 2
Reset camera’s point of view to scene2Shot1
Point the three trolls at the wizard
Set message’s onlyAffectYaw attribute to true
Friday, September 2, 2011
![Page 55: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/55.jpg)
55
Scene2Shot3
Friday, September 2, 2011
![Page 56: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/56.jpg)
56
THINKING IN 3D
Learn about 3D movement to work in Alice
Object’s position
Determines object’s location in the 3D worldObject’s orientation
Determines the way an object is facing
Friday, September 2, 2011
![Page 57: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/57.jpg)
57
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’s position in the world
– lr: point along the LR axis
– ud: point along the UD axis
– fb: point along the FB axis
Change an object’s position using move()
Directional values given with respect to object’s axes
Friday, September 2, 2011
![Page 58: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/58.jpg)
58
An Object’s Position (continued)
Friday, September 2, 2011
![Page 59: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/59.jpg)
59
An Object’s Position (continued)
Friday, September 2, 2011
![Page 60: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/60.jpg)
60
AN OBJECT'S ORIENTATION
Combines yaw, pitch, and roll (provides direction)
Yaw: amount of object’s rotation about the UD-axis
Example: turn(RIGHT, 0.25)
Pitch: amount of object’s rotation about the LR-axis
Example: turn(FORWARD, 0.25)
Roll: amount of object’s rotation about the FB-axis
Example: roll(LEFT, 0.25)
Friday, September 2, 2011
![Page 61: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/61.jpg)
61
An Object's Orientation (continued)
(pictures are better in the book!)
Friday, September 2, 2011
![Page 62: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/62.jpg)
62
An Object's Orientation (continued)
Friday, September 2, 2011
![Page 63: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/63.jpg)
63
An Object's Orientation (continued)
Friday, September 2, 2011
![Page 64: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/64.jpg)
64
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()
Friday, September 2, 2011
![Page 65: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/65.jpg)
65
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 a behavior for a single object
Comments: remarks that explain program statements
Friday, September 2, 2011
![Page 66: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/66.jpg)
66
SUMMARY (CONTINUED)
Alice clipboard: stores a copy of any statement
Dummy: invisible marker with position and orientation (a point of view)Object’s position: location specified using three coordinate axes
Object’s orientation comprises yaw, pitch, and roll
An Alice object has six degrees of freedom
Friday, September 2, 2011
![Page 67: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/67.jpg)
QUIZLET
1. From the editing area, you can drag any statement onto the ____________________ and Alice will store a copy of it there for you.
Answer:
2. A(n) ____________________ is an invisible marker in your world that has a position and an orientation.
Answer:
3. An object’s orientation is its combined ____________________, pitch, and roll.
Answer:
4. True or False: Alice objects have six degrees of freedom.
Friday, September 2, 2011
![Page 68: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/68.jpg)
QUIZLET ANSWERS
1. From the editing area, you can drag any statement onto the ____________________ and Alice will store a copy of it there for you.
Answer: clipboard
2. A(n) ____________________ is an invisible marker in your world that has a position and an orientation.
Answer: dummy
3. An object’s orientation is its combined ____________________, pitch, and roll.
Answer: yaw
4. True or False: Alice objects have six degrees of freedom.
Answer: True
Friday, September 2, 2011
![Page 69: CSCI 1111 - seas.gwu.edurhyspj/fall2011cs1111/lecture2.pdf · 14 METHODS FOR SCENES (CONTINUED) How to fix the first bug Click on the tab for my_first_method Drag a doInOrder control](https://reader034.vdocuments.us/reader034/viewer/2022051913/6003a310bd04ca4acd048723/html5/thumbnails/69.jpg)
DISCUSSION
1. How does decomposing a user story into scenes and shots help you organize the components of an Alice program? 2. What is the difference between a world method and an object method? 3. What is the value of adding comments to a program? 4. How does the use of dummy markers simplify the process of changing the camera object's point of view? 5. What is meant by the assertion that an Alice object has six degrees of freedom?
Friday, September 2, 2011