Friday, April 11, 2014

Section 2 Lesson 3: Chapter Summary & Projects

Chapter Summary & Projects
Section 2 Lesson 3: Using Procedures


Click here for Assignment as a Word Doc

Objectives

                   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 in a scene
                   Use procedures to move objects in a scene
                   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 

Vocabulary

Directions: Identify the vocabulary word for each definition below.


1.  An object's sense of direction.

2.  Program code executed once to define a single movement for an object in a scene.

3.  Tells Alice 3 how to implement the instructions in a program.

4.  A list of instructions that are required to accomplish a task.

5.  A piece of program code that defines how the object should execute a task.

6.  Sequence of numbers generated by a computer with no pattern in their sequence.

7.  Describes how to perform the procedure.

8.  Tell the objects in the animation how to perform tasks.



Go for it!

1.    (10 points) Create an animation with the correct procedures, directions, and distances based on the following scenario: A camel starts at the back left corner of the scene (the viewer's left), walks towards the camera 3 meters, then walks towards a rock 2 meters, stops for 2 seconds, then turns to the left 0.5 meters and walks forward 10 meters. Ensure that the animation works as intended at run-time, and debug if necessary.

2.    (10 points) Create an animation with the correct procedures, directions, and distances based on the following scenario: A ship starts at the back left corner of the scene (viewer's left), moves toward the camera 5 meters, then turns 1 meter to the right while simultaneously moving forward 10 meters. Ensure that the animation works as intended at run-time, and debug if necessary.

3.    (5 points) Add an object to a scene. Use a procedure to position the object so that it is 8 meters right, 1 meter above, and 15 meters in front of the center of the virtual world.

4.    (5 points) Add a tortoise and a hare to a scene in the grass template. Using the “drag and drop” method and handle styles, do the following:
a.    Drag and drop the objects so that the tortoise is to the left of the hare.
b.    Move the hare so it faces the back of the scene.
c.    Resize the tortoise so it is two times larger than the hare.
d.    Make the hare appear to lie down on the grass.

6(15 points) Create an animation for the following scenario: Five playing cards simultaneously move, turn, and roll in order. Create a new procedure for this motion. Run the animation, then alter the distance and duration argument values in the procedure and run the animation again to see how the playing card's movements change.

.    (15 points) Create an animation that uses the roll procedure to make three penguins appear to roll from the back to the front of the scene simultaneously. Hint: The penguins must be positioned on their side in the scene editor to achieve this motion. Once you make all three penguins roll, change the number of rolls to a random number between 1 and 5.

((5 points each classmate) With a classmate, conduct a peer review of your animation's code for one of your completed animations. Discuss what procedures and arguments you used, and what worked and didn't work

    I reviews the work of ______________________, and determined that ______________________________________________________.

8.    (5 points) In an animation scene, use five procedures that you have not yet used before. In your journal, create an entry entitled “New Procedures”. List the procedures you used, and describe how each instructed the objects to move.

9.    (10 bonus points) Create an animation for the following scenario: Place a teacup on top of a tea plate (MyProps class folder). Have the tea cup and tea plate turn simultaneously in opposite directions. Run the animation.  


Wednesday, April 9, 2014

Rotation and Randomization

Compare turn and roll procedures

Object movement


Object movement is egocentric – objects move relative to the direction they currently face.
An object can move in six directions:
  • Up
  • Down
  • Forward
  • Backward
  • Right
  • Left

Examples of rotation procedures


ProcedureDescription
Turn
Rotates objects left, right, forward, and backward on their center point.
Roll
Rolls objects left and right on their center point.

Comparison of turn and roll procedures


The object turns right and left on its center point using a vertical axis:
Turn 1
The object rolls right and left on its center point using a horizontal axis:
Roll 1
Some objects have moveable sub-parts that can turn and roll.
The pocketwatch has moveable hour and minute hands that can roll on the clock's center point:
Clock 1

Demo: Comparing different ways objects can turn and roll
Watch this video to see a comparison of turn and roll procedures.


Program objects to rotate

Object rotation


Steps to program an object to rotate:
  1. Select the instance of the object to rotate.

    Select Yeti
  2. Drag a turn or roll procedure to the Code editor.

    Select Turn
  3. Select a value for the direction argument.
  4. Select a value for the amount argument (1.0=one full turn or roll).

    Turn Arguments

Turn and roll procedures


ProcedureDescription
Turn
Rotates objects left, right, forward, and backward on their center point.
Roll
Rolls objects left and right on their center point.
Note: The key to successful rotation is knowing the center point of an object.

Demo: Programming objects to rotate
Watch this video to learn how to program objects to rotate in Alice 3.
Try It: Program an object to rotate
Download:
The Try it activity below requires that you start with the project file that was saved in the previous topic. Download this Alice 3 project file if you did not complete the previous topic's Try it activity.

Instructions:
  1. Open the WhiteRabbitProject file that you saved in the previous topic, or download the project file above.
  2. Program the White Rabbit to do one complete turn to the left.
  3. After a short delay, have the rabbit circle around the hedge and return to the same spot.
  4. Save the project.

Tuesday, April 8, 2014

3.3 - 3.5 Editing Arguments

Edit arguments

Arguments

Arguments are selected after the procedure is dropped onto the Code editor.
Argument types may include:
  • Direction
  • Amount
  • Duration
  • Text
Argument

The argument menu offers default argument values or, if none of the defaults are suitable, a custom option so that you can specify a more accurate argument value.

Terminology
An argument is a value used by the procedure to perform a precise task. A procedure may require one or more arguments that tell it precisely how to perform a task. Some examples of Alice 3 arguments are: object direction, direction amount, distance, and time duration.

Edit arguments


A procedure’s arguments may be edited or further defined to control object movement and timing.
An argument defines the degree to which an action is performed by the procedure.
Three Arguments

Steps to edit arguments


  1. Next to the argument’s value, click the arrow to display the menu of values.
  2. Select a new value.
  3. Use the Custom Decimal Number option to specify a value that differs from the default list of values.
Edit Arguments

Arguments as placeholders


When a procedure is dropped into the Code editor, all argument values must be specified even if you are unsure of the perfect value to use to perform the task. In those instances, you will select an argument value simply as a placeholder value that you will later replace.

For example, you may want an object to move forward but you're not sure how far. You can select a placeholder value of 2 meters, run the animation, determine that a larger number is needed, and then edit the value to something larger. You can also specify a placeholder value that will be replaced with a function or a variable. These techniques are described in another topic.

Demo: Editing arguments in procedures
Watch this video to learn how to edit the arguments in a procedure in Alice 3.
Try it: Edit arguments in a procedure
Download:
The Try it activity below requires that you start with the project file that was saved in the previous topic. Download this Alice 3 project file if you did not complete the previous topic's Try it activity.

Instructions:
  1. Open the WhiteRabbitProject file that you saved in the previous topic, or download the project file above.
  2. Edit the arguments in the move procedures so that the White Rabbit moves 1 meter to the left and then .25 meters to the right.
  3. Save the project.

Reorder, edit and delete

Steps to reorder programming statements


  1. Click the handle of the programming statement.
  2. Drag the programming statement to its new position.
  3. Drop the programming statement in its new position.
Note that a green position indicator line will appear to help you align the programming statement in the desired position.
Reorder

Edit programming statements


Use the drop-down lists to edit the values of the arguments in a programming statement.
Edit Arguments

Delete programming statements


Right-click programming statements to delete them.
Delete

Demo: Reordering, editing, copying, and deleting programming statements
Watch this video to learn quick ways to modify your code.

Test and debug

Edit and test the program


Run the animation to test it, and the edit the code as necessary. It may take several cycles of testing and editing to get the animation to run as desired.
Click Run2

Testing and debugging


Testing and Debugging is the process of running the animation many times, adjusting the control statements, procedures, and arguments after each execution to verify that the animation executes as expected.
Save often while debugging your program. 
Debug
You can insert temporary programming statements into your code to help with debugging. For example, if the baby yeti above is supposed to turn towards the hole in the ice, but he doesn't, you can insert a Say procedure just before the Turn procedure and click Play.
If the yeti Says something but still doesn't move, you know that the animation is at least reaching the Move procedure, so the problem lies within the procedure itself. However, if the yeti does not Say something, you know that the Move procedure is not the problem because the animation is not even reaching the procedure.
This is a simple example, but when working with complex animations where randomization or hidden movements are occurring, you may need to employ a debugging method such as this to help pinpoint the problem.

Demo: Testing and debugging the program
Watch this video to see an example of the testing and debugging process.
Try it: Test and debug the program
Download:
The Try it activity below requires that you start with the project file that was saved in the previous topic. Download this Alice 3 project file if you did not complete the previous topic's Try it activity.

Instructions:
  1. Open the WhiteRabbitProject file that you saved in the previous topic, or download the project file above.
  2. Test, edit, and debug the program so that the White Rabbit moves more gently using the animation style Begin and End Gently.
  3. Save the project.
Try it: Reorder, copy, edit and delete programming statements
Download:
The Try it activity below requires that you start with the project file that was saved in the previous topic. Download this Alice 3 project file if you did not complete the previous topic's Try it activity.

Instructions:
  1. Open the WhiteRabbitProject file that you saved in the previous topic, or download the project file above.
  2. Reorder the "Move" programming statements so that the White Rabbit moves right 1 meter, and then moves left 1 meter.
  3. Copy and edit programming statements so that the White Rabbit moves right .5 meters and then left 2 meters, and then right 1 meter.
  4. Delete a programming statement so that the White Rabbit no longer says "hello".
  5. Save the project.