Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Using Procedures
Using Procedures
Using Procedures
Prepare to Program
To prepare to program, use a top-down development approach: 1. Define the high-level scenario for the animation. 2. Document the actions that take place in the scenario, step-by-step, in a textual storyboard. Doing this helps you gain a thorough understanding of all of the actions that need to occur in the animation. 3. Create a table where you match the storyboard steps to the exact instructions that you need to program in Alice 3. 4. Review the table at several points during the animation's development to ensure you are creating it correctly and on-track to completion. Revise the table as necessary throughout the animation's development.
Using Procedures
Using Procedures
Using Procedures
Using Procedures
Using Procedures
Using Procedures
10
Using Procedures
11
Using Procedures
12
Using Procedures
13
Using Procedures
14
Using Procedures
Using Procedures
Programming Statements
The Procedures tab: Displays a pre-defined set for each class Displays procedures declared for the class Procedure examples: Move Turn Roll
A procedure is a piece of program code that defines how the object should execute a task. Alice 3 has a set of procedures for each class, however, users can create (declare) new procedures.
16
Using Procedures
Programming Arguments
There are two components that follow the name of the object in a programming statement: Procedure name Procedure arguments Programming arguments initially display with ??? to indicate the location at which the argument will be placed.
Procedure Arguments
17
Using Procedures
18
Using Procedures
19
Using Procedures
20
Using Procedures
Executing A Program
Click the Run button to execute the programming instruction.
21
Using Procedures
Object Direction
An object can move in six directions: Up Down Forward Backward Right Left
Object direction is egocentric. For example, if an object is facing you, and you specify an instruction for the object to turn left, the object will turn to its left, not to your left.
22
Using Procedures
Move Procedure
The move procedure moves the object in all six directions. You select the direction and distance to move.
23
Using Procedures
24
Using Procedures
25
Using Procedures
Move To Procedure
The move to procedure will move an object the distance to the center of the target object. You select the object to move to, and the program calculates the distance for you.
You may want to use additional procedures to adjust the position of the moving object so it does not stay in the center of the other object.
26
Using Procedures
27
Using Procedures
Delay Procedure
The Delay procedure will halt an object for a specific number of seconds. You select the number of seconds to delay until the next procedure is executed.
In this example, the clock delays one second, then the hour hand on the clock rolls to the left 0.25 meters.
28
Using Procedures
Say Procedure
The Say procedure will create a call out bubble with text to make an object appear to talk. You can use the pre-defined text or choose to annotate your own text.
29
Using Procedures
Rotation Procedures
There are two procedures for rotating objects: Turn Roll The turn procedure rotates objects on their center point: Left Right Forward Backward The roll procedure rolls objects on their center point: Left Right
30
Using Procedures
Stationary
Right Turn
Left Turn
The object below rotates (rolls) on its center point, right and left.
Stationary
Right Roll
Left Roll
31
Using Procedures
Some objects have sub-parts that are also movable. In this example, the pocket-watch object has hour and minute hand sub-parts. The sub-parts may be animated to roll on the clock's center point.
32
Using Procedures
Above, the object's sub-part (its head) displays rings; the rings show the sub-parts' range of motion.
33
Using Procedures
34
Using Procedures
35
Using Procedures
Control Statements
Procedures listed in the code editor will execute sequentially unless instructions are given to the program to execute in a different manner. These instructions are referred to as control statements. Control statements define how to execute a sequence of programming statements in a manner other than sequentially. Examples: Do in order: Execute statements in sequential order; referred to as sequential control Do together: Execute statements simultaneously Count: Execute statements a specific number of times While: Execute while a condition is true
36
Using Procedures
Using Procedures
38
Using Procedures
39
Using Procedures
40
Using Procedures
41
Using Procedures
42
Using Procedures
43
Using Procedures
44
Using Procedures
45
Using Procedures
Random Numbers
Random numbers are a sequence of numbers generated by the computer with no pattern in their sequence. For example: 15674 -6934022.1133 03 Computers require random number generation for: Security: Randomly generated passwords Simulation: Earth science modeling (e.g., erosion over time)
46
Using Procedures
47
Using Procedures
48
Using Procedures
Then you specify the values desired from the list of available values or by specifying a custom decimal number for each range value.
49
Using Procedures
50
Using Procedures
51
Using Procedures
Terminology
Key terms used in this lesson included: Argument Control statement Instructions Orientation One shot procedure Procedure Program Random numbers
52
Using Procedures
Summary
In this lesson, you learned how to: Toggle and describe the visual difference between the scene editor and code editor Correlate storyboard statements with program execution tasks Identify the correct procedure to move an object Use procedures to move objects Add Java programming procedures to the code editor Demonstrate how procedure values can be altered Add a control statement to the code editor Use random numbers to randomize motion
53
Using Procedures
Practice
The exercises for this lesson cover the following topics: Working with the code editor tools Creating a program with procedures Using random numbers to randomize motion Presenting your work
54