CompSci 94 - Classwork 6 - Sept 12, 2013
10 pts

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.

  1. 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).

  2. 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.

    1. Download skyride.a2w from the CompSci 94 calendar page for today.

      (TROUBLE SHOOTING: Your laptop may rename the file when it downloads it as or Your laptop does not know about alice worlds and thinks the file is a .zip file. If this happens you should try to rename it back to skyride.a2w. This may be difficult to do. DO NOT UNPACK THE .ZIP FILE or EXTRACT FILES FROM IT.
      ALTERNATIVELY, you can still load the file with the .zip extension, because it really is an Alice world that just has a bad file extension and not a .zip file. In Alice, when trying to open the file, at the bottom 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 or it really is an Alice world).

    2. 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.

    3. Create a Dummy Camera object called originalPosition, to save the original camera position (always a good idea!).

    4. 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 side.

    5. Animation Code
      Your code should show the skyride animation from a distance first and then 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 (the tripod you already set)

      • 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.

  3. Helicopter Flight

    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.