240 likes | 376 Views
Creating An Animation Program. Alice. Recall. We began the animation creation process We introduced the concept of an algorithm We introduced the concept of a storyboard Visual: sketches or screen shots Textual: to-do-list. Today’s Focus. Animation Programming Read scenario
E N D
Recall • We began the animation creation process • We introduced the concept of an algorithm • We introduced the concept of a storyboard • Visual: sketches or screen shots • Textual: to-do-list
Today’s Focus • Animation Programming • Read scenario • Design storyboard • Implement • Test results
Implementation • Toimplement the storyboard, translate the actions in the storyboard to a program. • Program (a.k.a. script) • a list of instructions to have the objects perform certain actions in the animation
Writing the Program • Suppose the Scenario is to animate a snowman trying to get the attention of a snowwoman who is having a conversation with another snowwoman. • The planned storyboard (to-do list) might be: • Now the design steps need to be translated into program instructions. Do the following actions in order snowman turns to face snowwoman snowman says something snowwoman turns head snowman “raises eyebrows” snowwoman blushes as she turns head back around
Translating the Design • Some steps in the storyboard can be written as a singleinstruction • The snowman turns to face the snowwoman • Other steps are composite actions that require more than one instruction • Moving the snowman’s eyebrows (eyes) consists of two actions happening together • The left eye moves up and then down • The right eye moves up and then down
Action Blocks in Alice Sequential Action Block Simultaneous Action Block
Writing the Program • In-class example: the implementation process • The finished program: • Ch02Snowpeople
Concepts in this first program • Program instructions may have arguments • Example: for the move instruction, the arguments we used in this example were • direction • distance • DoTogether and DoInOrder blocks can be nested: one inside the other
Testing • An important step in creating a program is to run it – to be sure it does what you expect it to do. • We recommend that you use an incremental development process: • write a few lines of code and then run it • write a few more lines and run it • write a few more lines and run it… • This process allows you to find any problems and fix them as you go along.
Comments • While Alice instructions are easy to understand, a particular combination of the instructions may perform an action that is not immediately obvious. • Comments are used to document the code – explain the purpose of a particular segment of the program to the human reader.
Demo • Ch02SnowpeoplewithComments • Comments in this example world illustrate • description of the action performed by the entire method • description of the purpose of a small segment of code
Chapter 2 Tips & Techniques • Orient to method • Every Alice object has an orientation: a definition of which way is forward, backward, etc. • Not all objects have the same orientation • When 2 objects need to move together, use the orient to method to get them oriented the same way • Each object must be given a move instruction
Chapter 2 Tips & Techniques • The vehicle property • Another way to get two objects to move together in the SAME direction • Select the rider object and the properties tab • Select the other object to be the vehicle • When an instruction is given to move the vehicle, the rider moves with. • The rider may move independently of the vehicle, however.
Chapter 2 Tips & Techniques • Arguments • Duration: default is 1 second • Style: how movements blend together – may help the “smoothness” of your animation • Gently (begin and end), begin gently, end gently • Abruptly (begin and end), begin abruptly, end abruptly • asSeenBy • Controls the movement of an object relative to another, such as the ground, rather than moving the object according to its orientation
Chapter 2 Tips & Techniques • turn to face method • Pivots an object until its front is facing the other object • point at method • also turns an object to face another, but their centers are aligned • can cause a tipping effect if the two centers are at different heights • adjusting the onlyAffectYaw to be true makes this method equivalent to turn to face
Chapter 2 Tips & Techniques • move to method • moves one object to another so that their centers meet • could cause a collision • move toward method lets you specify how far to move
Saving Your WorkUSB Drives • Flash/USB drive • Name your drive • Go to My Computer • Locate the drive (probably E:\) • Right-click and choose rename • Give it your name (also helpful if you forget it somewhere!) • Be sure the drive is inserted before starting Alice
Saving Your WorkUSB Drives • Properly eject the USB drive by clicking on the Safely Remove Hardware button in the notification area of the taskbar (lower right corner)
Saving Your WorkUNCW Student Servers • Student FTP – this uses your space for UNCW student web pages - http://www.uncw.edu/itsd/students/ieupload.htm • Timmy Server – http://www.uncw.edu/itsd/students/studentfilesrv.htm
Assignment • Read Chapter 2 Tips and Techniques, and Chapter 3, Section 1: Built-in functions and expressions
Lab • Chapter 2 Section 2 Lab