Alice 2.2- Easy homework
IST240: Project 4 Active-Learning Exercise – Simple Flight Simulator
Building a Simple Flight Simulator
Problem: In this exercise, you will build a simple flight simulator1. You will start with a water world, add a
seaplane to the world, build events to allow the user to control the plane, and then add other objects to the world
to make it look more interesting. You will create the following keyboard controls for the seaplane:
- turn the plane forward (nose down)
- turn the plane backward (nose up)
- turn left
- turn right
You will also modify world.my first method to keep the plane in motion with its propeller spinning,
and create an event to activate this method while the world is playing. When you are finished, you will have a
world that functions as a simple flight simulator, and that you can further develop on your own into a more so-
phisticated flight simulator or game.
Instructions: First, start a new Alice world and add a seaplane.
1. Open Alice and begin a new world with the water template.
2. Click the ADD OBJECTS button to enter Scene Editor mode, then open the Vehicles folder in the
Local Object gallery.
3. Click the Seaplane Class tile and then click the Add instance to world button to add a sea-
plane to the world.
4. Turn the seaplane so that it is facing away from the camera and slightly to the right, then reposition
the camera using the blue camera control arrows so that the view in the World window looks similar to
the following example.
5. Click the DONE button to return to the standard Alice interface and then save the world with the file-
name, Lab 4-1 flight simulator.a2w, before continuing.
1 G. Shelly, T. Cashman, C. Herbert, “Project 4 - In the Lab 1: Building a Simple Flight Simulator”, Alice 2.0 Introductory
Concepts and Techniques, Thomson Course Technology, 2007, pp. 226-229
Next, you add four events to steer the plane. Begin by creating an event to turn the plane forward, which will
turn its nose downward. You will then copy and modify this event to create the three other steering events.
6. Click the create new event button in the Events area and then select when a key is typed
from the menu that appears. A new When any key is typed, do Nothing tile will ap-
pear at the bottom of the Events area.
7. Right-click the new event tile, point to change to on the menu that appears, then select While a key is pressed.
8. Click the any key parameter in the new event tile and then select Up from the menu that appears.
9. Click the seaplane tile in the Object tree and the methods tab in the Details area, then drag a copy
of the seaplane turn at speed tile and drop it in the new event following During:. Select
forward and .25 revolutions per second from the menus that appear.
Now copy the event to the Clipboard and, one at a time, build the three remaining turn controls from the copy.
10. Drag a copy of the new event from the Events area and drop it on the Clipboard. 11. Drag the content of the Clipboard and drop it in the Events area, below the existing events.
12. Click in the new copy of the event, then select Down from the menu that appears.
13. Click the forward parameter in the turn at speed instruction in the event handler of the new
copy of the event, and select backward from the menu that appears.
14. Again, drag a copy of the contents of the Clipboard into the Events area. In this copy, change to
Left and change the forward parameter to left.
15. Once more, drag the contents of the Clipboard into the Events area. In this copy, change to Right
and the forward parameter to right.
16. The four turn events are now complete. Save the world again, and then play the world to test the events. The plane should turn in place in response to you keystrokes, but it should not yet move. If it does not
respond correctly, then carefully retrace the steps above to find and correct the error.
Next, you will add an event to make the plane move and the propeller spin. Instructions to do both of these ac-
tions will be in world.my first method. Also, modify the default event so that world.my first
method continues to run while the world plays, and does not run only once when the world starts.
17. Drag a copy of the Do together tile from the bottom of the Editor area and drop it in world.my
first method in place of Do Nothing.
18. Drag a copy of the seaplane move at speed tile from the methods tab and drop it in the Do
together tile in place of Do Nothing. Select forward and 10 meters per second from
the menus that appear.
19. Click the plus sign next to the seaplane tile in the Object tree, and then click the propeller tile to
select the propeller.
20. Drag a copy of the propeller roll at speed tile from the methods tab and drop it in the Do
together tile, below the seaplane move at speed tile. When the menu appears, point to
right, then click other and us the Custom Number dialog box to enter 10 as the number of revolu-
tions per second.
21. Right-click the When the world starts default event tile in the Events area. When the menu
appears, point to change to, then select While the world is running.
22. Click the world tile in the Object tree. Drag a copy of the my first method tile and drop it in
place of None in the While the world is running tile in the Events area, following the word
During:.
23. The changes to the default event and world.my first method are now complete. Save the world
again and then play the world. This time, the turn controls should work and the plane should move with
the propeller.
You can now fly the plane, but you can easily fly it off camera and lose track of where it is. Next, add mouse
events to the world to control the camera: one to allow the user to move the camera, and one to point the camera
at the plane. These will allow you to follow the plane as it flies around, and to find the plane if it moves off
camera.
24. Click the create new event button in the Events area and select Let the mouse move the
camera. This is a built-in event type; you do not need to do anything else to create the complete event.
25. Click the create new event button and select When the mouse is clicked on something from the
menu. Scroll to the bottom of the events area to see the new event tile.
26. Click the camera tile in the Object tree, then drag a copy of the camera point at instruction tile
and drop it in the new event in place of Nothing, following the word do. When the menu appears, se-
lect seaplane. The new event now reads When the mouse is clicked on anything,
do camera point at seaplane. Save the world before continuing.
Your two new events are complete and ready to be tested. While the world is playing, click and drag the mouse
pointer forward, backward, left, and right in the playing world window to move the camera. You can pan left
and right and zoom in and out. Simple click the mouse without dragging it to point the camera at the plane.
These controls will work while the keyboard controls are being used to fly the plane. One person can operate
both the mouse and the keyboard using two hands, or two people can work together – one flying the plane and
the other operating the camera.
To add sound to this project:
1. Click the seaplane tile in the object tree. If necessary, click the method tab to display the sea-
plane object’s methods.
2. Click create new method from the method tab. Type playSoundFile in the Name text box.
Click OK to continue.
3. Drag a copy of the seaplane play sound tile from the methods tab and drop it in the blank area
below Do Nothing in the Editor area. Click import sound file from the sound menu and
navigate to the Sounds folder for Project 4 that was downloaded from ANGEL. Click the sea-
plane.wav file and then click Import to continue.
4. In the Events area of the Alice interface, click create new event and click when the world
starts from the menu. Scroll to the bottom of the Events Window and right-click on the blue shaded
box of the when the world starts instruction tile and select change to, then While the
world is running in the drop-down menu.
5. In the While the world is running instruction tile, left-click the None drop-down menu to
the right of the During box. Select seaplane, then select playSoundFile.
6. Click File on the menu bar, then click Save World on the File menu to save the world again with
the sound file.
7. Click the Play button in the top left corner of the Alice interface to play the world, and see how it
works.
8. Click the Stop button when finished playing the world.
Your final task in this exercise is to populate the world with several objects to make the scene more interesting
as in the example below. For example, you could place a lighthouse in the distance, and then fly the plane
around the lighthouse. Several folders, particularly the Vehicles folder and the Beach folder, contain object that
you can place in the water to make your world more interesting as you fly the plane. The Environments folder
contains two different islands. Once you have created a world you like, save the world.
Also, remember that you can use the Take Picture button while the world is playing to capture an image of
the plane in your virtual world. Perhaps you can fly the plane near some of the objects you add to the world and
capture it in an interesting position while the world is playing.
Congratulations…..your flight simulator world is now complete!