CS 2, Winter 2009
Programming for Interactive Digital Arts

SA 5, due Fri, Jan 16

To practice conditionals + state, write a sketch that does the following.

  1. A ball starts off in the middle of the window.
  2. Every frame, it takes a random step: its x and y coordinates are incremented/decremented by random values according to the current "step size". It never leaves the window.
  3. The step size starts at 2, so that a step is between -2 and +2. While the mouse is in the left 1/3 of the window, the step size is decreased by 0.1 per frame, down to a minimum of 1. While the mouse is in the right 1/3 of the window, it is increased by 0.1 per frame, up to a maximum of 20. (If the mouse is in the middle, the step size doesn't change.)
  4. The size (width and height) of the ball starts at 5. While the left mouse button is pressed, the size is increased by 0.1 per frame, up to a maximum of 20. While the right mouse button is pressed, the size is decreased by 0.1 per frame, down to a minimum of 1.
  5. Each time the 'c' key is pressed, the fill color is set randomly (it starts off as white).
  6. The background is black, and there is no fade-away.
screenshot[applet]

As always, turn in the zipfile on Blackboard, as SA 5 in the Assignments section. In the field where you can type in some information, please tell me roughly how long this assignment took, and if there were any particular difficulties.