CompSci 4 - Classwork 6 - Sept 15, 2011
Today's classwork goes along with Chapter 4, Section 1.
You will create three Alice worlds today.
The following work needs to be checked off when you have completed it.
- Copy your previous "snowman tries to meet snowwoman"
world (from Chapter 2, section 2) and rename it to snowmanFliphat.a2w.
You will modify this world
to create two methods. (you can load the world in Alice and then select
"File - Save as" to save it as another world or just copy it as you
copy files on your computer).
- catchAttention World method - The snowman should turn to face the camera, say Ahem,
and then turn to face the snowwoman. This method should be called
twice in your "my first world" method with the snowman moving forward
between the calls.
- flipHats World method - The snowman uses his right arm to tip his hat
and the snowwoman's hat moves up and down quickly.
This method should be called at least twice
in your "myFirstWorld" method.
- Moving a camera along with an object and go to the NC State Fair next fall!
In this part you will setup a Camera view to move with an object.
All the code entered will be placed into world.myFirstMethod.
- Download skyride.a2w from the CompSci 4 calendar page for
(TROUBLE SHOOTING: Your laptop may rename the file when it downloads it
as skyride.zip or skyride.a2w.zip. Your laptop does not know about alice
worlds and thinks the file is a .zip file.
DO NOT UNPACK THE .ZIP FILE or EXTRACT FILES FROM IT.
If this happens you should try
to rename it back to skyride.a2w. This may be difficult to do.
ALTERNATIVELY, you can still load
the file with the .zip extension, because it really is an Alice world and
a .zip file. In Alice, when trying to open the file, at the
of the window, there is an option "Files of Type:". The default is
A2W files. Instead select "All files" and you will be able to load
skyride.zip or skyride.a2w.zip(because it really is an Alice world).
- Play the world to see what it does. The world has a
fair ride of skycars. All the skycars start at the same position, then
one by one they move across and back, ending at the same position.
Skyride.Car1 is first, followed by Skyride.Car2, followed by Skyride.Car3.
- Create a Dummy Camera object called originalPosition, to save
the original camera position (always a good idea!).
- Create another Dummy Camera object that has the view of Car2 in the
skyride. Before dropping the dummy camera, you should move the
camera down 0.5 meters as the default is the roof of the car. This will
give more of a rider's perspective. Also, before dropping the dummy
camera you should move the camera
to the right about 0.5 meters. This will allow a clearer view from the
- Animation Code
This code will show the skyride animation from a distance first
the camera will attach to Skyride.Car2 and you will get to watch the
skyride animation a second time as if you were riding in Car 2.
- In world.myFirstMethod copy the one line of code
Skyride.skyrideAnimation so it occurs twice.
- In world.myFirstMethod add a new command in the program
BEFORE the second
Skyride.skyrideAnimation. The command to add is for the camera
object to set the point of view to your dummy camera for
Skyride.Car2. This adds the point of view to the roof of SkyRide.Car2.
To get the riders perspective, add a command after this one to move the
camera down 0.5 meters.
- Play the world to see what happens. Why doesn't the camera move?
- Add a command to the program immediately after the last
command you added and before the second SkyRide.skyrideAnimation.
The command to add is to make the camera move when SkyRide.Car2 moves.
(see vehicle property from last class).
- Add one last command after the second
SkyRide.skyrideAnimation to set the point
of view of the camera
back to the original position.
- Play your world to see what happens.
- ADD IN ANOTHER RIDE. Go to the Amusement folder and add in one other ride such as
the octopus, carousel, or swings.
You will need to change the
camera view as if you are riding this ride
and create another dummy camera similar to what you did for the
Play the animation
once with your view of riding it.
NOTE THIS RIDE MAY BE SETUP TO RUN FOREVER so it may not stop.
If that is the case, then your world just won't stop, that is ok.
Create a world (name
it helicopterFlight.a2w, with a helicopter (Vehicles folder),
airport(Buildings), and a control tower(Buildings). Create a
circleTower method that makes the helicopter fly toward
the control tower and then around it. In myFirstMethod,
call the circleTower method twice and then make the helicopter
land on the airport landing strip.
Note that if your helicopter goes out of sight, it may not be close
enough to the tower, try moving it in closer before having it circle.
If you finish early, feel free to embelish your animations.