Alice Concepts:  Camera Operation, Arrow Events for Driving, and Loops

Review of Alice Key Vocabulary:

Key Vocabulary:

Objects: Anything in an Alice World. 


Methods:  Actions objects do.  Programmers can create new Methods by stringing other Methods together.


Events: Events are anything a User or "outside force" does to a program.  An event is like a User input.

User Left Clicking Mouse on an icon.
User typing a Key.

Vehicle:  All Alice objects are attached to a "Vehicle."   All movement by the object is done in relation to the Vehicle.  If a Vehicle moves, the Object moves with it. 

For example, if you have a scene where you have a "Human" and a "Car," and you want the Human to "ride" or "stick" to the Car.  In the "Human's" properties tab, you would set the Vehicle=Car.  Thus, when the Car moves around the World - the Human goes with it.  

By default - Alice Objects Vehicles are set to the "World."

In Alice programming - you assign Methods to Events:

For Example:

1.  Programmer creates Method "DriveForward" in Car Object
2.  Programmer creates Event "When Up Key pressed -> The Car DriveForward Method is called to action."
3.  When Up Key pressed, do Car.DriveForward

Keyword Chart:

Objects: "Things" in Alice World
Methods: What Objects Can Do
Make Sounds
Change Shape
Change Properties
Properties: Qualities Objects Have
Orientation in space

Alice Project:  Simple Driving Game

Alice has a pre-made Event for using the arrow keys to "drive" an object through the world.  The object can be an animal, person, thing, or vehicle.

In addition, the camera can have its "vehicle" set to the driving/moving object.  Allowing the view/player of your program to have a 1st Person view.  This short project will demonstrate:

1. Creating a method to have an object drive in a square path in the world.
2. Setting the Camera Vehicle to the driving object so the camera follows in a square.
3. Setting the Camera to stay at a fixed point and point at a moving object
4. Using Arrows and Events so the User can drive the object about the world.

Project 1:  Drive in a square

1. Open Alice
2. Start a new world.
3. Click "Add Objects."  Select the "Vehicles" and then "convertibleCorvette" and add it to the world by clicking the object.


4. Use the Positioning Icons to turn and place the car facing away from the camera.

5. Click "Done"

6. Click on the "convertibleCorvette" in the object tree.
7. Click on the "methods" tab and click "create new method."
8. Name the method "square."

9. Drag a Loop block into the "square" method.  Select 4 times

10. Drag a block into the Loop and select "50 meters."



11. Drag a into the Loop and select "left -> 0.25 revolutions."


12. Click on " first method" tab.

13. Drag the "square" method from the convertibleCorvette into " first method."  It should look like this

14. Click "Play."  Your car should drive in a square.
15. Save your work in your file area as "Lastname Driving"

Project 2:  Camera Follows Car in square

1. Click on " first method."
2. Click on "camera" in the object tree.
3. Click on the "properties" tab.
4. Drag the "vehicle" block into the " first method" above the square block

5. Select "convertibleCorvette" for the vehicle.
6. " first method" should look like this:

7. Click "Play" and see if the camera stays with the car.
(You might want to add some other objects (buildings, people, other vehicles) to give the space a sense of direction.  Do not add more than two other objects.

8. Save your work.

Project 3: Setting the Camera to stay in one spot and point at moving object

1.  Start with the "Lastname Driving" program you created in previous projects.
2.  Click on the " first method" tab.
3.  Delete the "Camera Set Vehicle to 'convertibleCorvette'" block.  (Drag Block to Trash Can)
4.  Add a Loop block above the convertibleCorvette.square block.  Select Infinite Loop.

5.  Click on Camera in the Object Tree
6.  Click on the methods tab.
7.  Drag "Camera point at" into the Loop Block.  Select "convertibleCorvette."

8.  Drag a "Do Together" block below the "convertibleCorvette.square" block.

9.  Set Duration to 0 Seconds in "camera point at" block
10.  Put the "convertibleCorvette.square" and the Loop inside the "Do Together."

11. Click Play and see if the camera points at the moving car.
12. Save your work.

Project 4:  Using Alice preset Arrow Events to "Drive" object through world.

1.  Start with "Lastname Driving" program you created in previous projects.
2.  Click on "create new event" in the Events Pane

3.  Select "Let the arrow keys move <subject>"
4.  Select "convertibleCorvette" in the event icon.

5.  Your script should look like this:

6.  Click "Play" -> Your car should drive in a square.  Then you can type the arrow keys and move the car around the world.  
7.  Save your work.