Lab Exercises, 6 March
Home   Lectures   Solutions   Syllabus      Instructor's Site  
Lab Exercises, 6 March

  1. (Lab6MarchEx1.a2w) Create a world with a frog (Animals) and a ladybug (Animals). Write an interactive program to allow the user to drag the ladybug around the scene. (Use a let the mouse move objects event.) As the ladybug is dragged around, make the frog chase after it by moving one hop at a time. If the user moves the ladybug within 2 meters of the frog, have the frog look at the camera and say "ribbit" -- then end the animation.
  2.  
  3. (Lab6MarchEx2.a2w) Extend the world you created in the previous exercise with the following steps. The structure of this solution is very similar to what we built for Homework 5.
       
    • Count the number of hops the frog makes.
    •  
    • If the number of hops reaches 5 before the frog gets within 2 meters of the ladybug:
         
      • Make the frog's head turn to face the camera, and have the frog say, "Whew! I'm tired."
      •  
      • Start counting over from 0.
       
    • The frog should continue hopping after the ladybug, stopping to take a break only every 5 hops.