CompSci 4 - Classwork 14 - Oct 25, 2011
10 pts

Today's classwork goes along with Chapter 7, Section 2 and Tips and Techniques, and covers more "while" loops, with and without events, and "when" with event.

The following work needs to be checked off when you have completed it.

Part 1

Make a copy of the ClickACow world you created last time and name it ClickACowGame2.a2w. Modify the game to use a "while" statement so that the game stops as soon as one of the following things happens: The cow has been clicked on the targetted number of times, or the timer has run down. The cow should say an appropriate message as it did last class period.

Part 2

  1. Create a new Alice world with snow or ice that has a penguin and a fish lying on top of the snow or ice.

  2. Use the Event loop BDE (Begin During End) to have the penguin move over to the fish, bend over and eat it whenever the fish is visible (fish should disappear when he eats it).

    Note: DO NOT use the "walk" penguin method, there appears to be a bug in it. You can just move the penguin forward 1 meter.

  3. Add another event (when you press a key) to make the fish appear (no longer invisible) in a random place on the ice. Try pressing this key after the penguin has eaten the fish so the fish reappears somewhere else and the BDE event kicks in again,so the penguin goes over to the fish and eats it.

  4. Add a zamboni (vehicle folder) to the world. Add the "Let the arrow keys move" event and use the arrow keys to control the zamboni.
  5. Add an event ("when something is true") so that when the penguin is close to the zamboni, then he gets up in the drivers seat and "sticks" to the seat (vehicle property). You should then control the zamboni with the arrow keys to have it drive away with the penguin. You also do not want the penguin to try to eat the fish if it becomes visible and the penguin is on the zamboni.

    NOTE: How do you find this event, it is hidden. See the lecture notes.

    NOTE2: The zamboni is one big object, no parts. You might want to glue an invisible object near the entrance to the driver's seat and compare if the penguin is close to the invisible object.

    NOTE3: You don't want your BDE to kick in while the penguin is on the zamboni. How do you prevent this?

  6. Create an event for the penguin to dismount back to the ground (and reset the vehicle property). If the fish is visible then that event should kick in once the penguin is unglued.
  7. You should create Instructions (billboard or 3D text).
  8. Play your world, whenever the fish is visible and the penquin is on the snow or ice, it should go over and eat it. Whenever the zamboni is close to the penguin, he should go sit in the driver's seat. Play it with these things happening at least twice each.

If you finish early, feel free to embelish your animation.