Lab 8: Event Driven Programs

In this lab you will learn how to create simple event driven programs. The lab consists of two example from the book:

a. Complete exercise 14. Penguin Slide, from chapter 5. The file Lake with hole.a2w has the world set up for you.

Place three penguins on the hill. When a penguin is clicked it should lie on its belly and slide down the hill, spinning on its belly at the same time. then it should hit the water and disappear into the water with a splash.

Hint, define appropriate method(s) for one penguin, then save and import to get three penguins. Use the mouse clicked event to determine which penguin does the action.


b. Complete project 4, "Robot Preparing for Competition" from chapter 5, with the following hints and additions.

For the ground skinTexture, add the object (the example given is fire from special effects) from which you want to take the texture, then change the ground skinTexture to its texture (under properties). If you do not want the object in the scene, simple move it to the side off screen.

Define a robot (Ranger) method for each action, then invoke that method with an event key.

For your choice of action, be sure to add an event key to invoke it.

As an alternate option (your choice), you can use mouse click events on parts of the robot to invoke the actions.

As an option, you can use an object different from Ranger for your robot.

Include a while event such that the robot jumps up and down when invoked, then continuously cycles through the other actions as long as the while condition is true, ending with another jump up and down.


In both problems you should use both world methods and class methods as appropriate, so that the event specifications simply call the appropriate method, with the needed parameters.

grading standards