CS105L Introduction to Game Programming Using Alice (Lab)
Fall 2009
LAB 8
Chapter 5 and 6
Covers material from Chapters 5 & 6 in class text; Starting Out
with Alice.
Part 1 - Chap 5: Passing an object as a parameter – Marcello the
Magician
-
Complete exercise 5-5 on page 237.
-
Save the object. Refer to tutorials 5-2 pg 194 and 5-4 on pg
205 for saving objects and passing parameters.
Part 2 – Key pressed events - Spacejet
-
Complete tutorial 6-2 pg 250 with additional steps below.
-
Modify your code such that the spacebar causes the Spacejet to
hover only. Add additional events to use the arrow buttons to
control forward, back, left and right turns.
-
Extra; complete rest of lab first. Tap the spacebar once to
rise. A second tap will land the jet. The keys “s” and “d”
will raise or lower the jet in flight. Add banking when the jet
is turning. The “x” key will cause an ejecting of the pilot.
Add a sounds for when the jet is hovering, turning, and flying.
Part 3 – Mouse clicked events – The fridge
-
Complete tutorial 6-3 pg 253 with additions below.
-
Modify your code such that clicking on the door a second time
will cause the door to close.
-
Add code to open/close the freezer door by clicking on the
freezer door.
Part 4 – Combining 1 & 2; adding sound.
-
Create a new world. Add the new magician class you created in
part 1.
-
Select file from top tool bar.
-
From the file drop down select import.
-
Navigate to where you saved the magician class and select
import.
-
Modify the code from part 1 such that an object will disappear
when clicked on. That is, clicking on an object with the mouse
will call the disappear method on that object.
-
Add a sound effect when the object disappears.
-
Adding sounds: Select the properties tab of the object (or
world).
-
Expand Sounds.
-
Select import for an existing sound file or record to create
a new sound file.
-
Playing a sound: from the properties tab drag the sound into the
editor.