Program Design and Implementation
Program Design and Implementation
Implementation
Chapter 3
Pemrograman Visual
Object Movement
• Professional animators begin their process by developing a
scenario—or story—that gives the animation a purpose.
• Examples:
– A story representing a conflict and resolution.
– A lesson to teach a math concept.
– A process to simulate or demonstrate.
– A game to play for entertainment or training.
1. Scenario
• Defining the scenario, and the animation to represent the
scenario, is the first step to programming your animation
• Professional animators begin their process by developing a
scenario—or story—that gives the animation a purpose.
• Examples:
– A story representing a conflict and resolution.
– A lesson to teach a math concept.
– A process to simulate or demonstrate.
– A game to play for entertainment or training.
2. StoryBoard
Visual Storyboard
• A visual storyboard helps the reader
understand:
– The components of a scene.
– How the initial scene will be set-
up.
– The moving and non-moving
objects in a scene.
– The actions that will take place.
– The user interactions that will
occur during the animation
execution.
Textual Storyboard
• A textual storyboard helps the reader understand the actions
that will take place during the animation.
• The moving and non-moving objects can be easily identified
within the action statements, but a more detailed description
may be necessary if additional programmers are also involved
in implementing any scene
• Program the following actions in order:
– Boy and girl sit on a park bench.
– Boy stands up and walks away, leaving his
mobile phone on the park bench.
– Girl turns to look at the phone.
– Girl thinks, "Hey! That boy forgot his
phone!"
– Girl says out loud, "Hey! You forgot your
phone!"
– Boy stops and turns around.
– Boy walks back to the park bench and says,
"Oh! Thank you!"
3. Implementation
• Using Storyboards to Organize Your Program
• Textual storyboards can be used to generate program
comment statements and organize program development.
• Storyboards can also help programmers identify repetitive
actions for one object, and identical actions that may be
performed by multiple objects.
Class Inherits
• objects in the programming world inherit the characteristics of their
class, including all of the class's methods (procedures and functions).
• For example, all objects within the quadruped class in Alice
inherit the quadruped characteristics of four legs, a head, a
body, etc
Identifying Repetitive Behaviors in Your
Storyboard
• Understanding that subclasses belong to superclasses helps
you, as a programmer, identify repetitive behaviors in your
storyboard.
• For example:
– If you plan to program a dog, cat, and lion to walk, you should program
the repetitive behavior of walking at the superclass, or quadruped,
level.
– The result is that all of the subclasses (dog, cat, lion) can use the
inherited characteristic of walking, and you do not have to program the
repetitive walking behavior for each object individually
Procedural Abstraction
• Review the existing code or the textual storyboard to identify and plan the methods that you
need to declare in your program.
• Procedural abstraction may need to be implemented if an object in Alice needs to perform an
action, but there isn't an inherited procedure that accomplishes that action.
• Identify a repetitive behavior and create one method for it:
• Simplifies the code, making it easier to read.
• Allows many objects of a class to use the same method.
• Allows subclasses of a superclass to use the method.
Example procedural abstraction 1:
Example procedural abstraction 2:
When to Declare a Procedure
• Declare a procedure when:
– Motions do not have a default procedure, such as a bird flying.
– Motions need to be used by multiple objects or classes, such as all
quadrupeds hopping up and down.
– Singular motions require many programming statements, such as a
person moving body parts to walk.
Declaring a Procedure Example
4. Testing
• Evaluating an animation
Argument
Simultaneous Movements
Walking Textual Storyboard Example
When Procedures Offset Each Other
• A common mistake is to include two procedures that cancel
each other in a Do together construct.
• For example, if you include a move up 1 meter procedure,
followed by a move down 1 meter procedure in a Do
together, nothing will happen.
• The procedures cancel each other out.
setVehicle Procedure Example :
Steps to Use setVehicle Procedure