CS 2, Winter 2009
Programming for Interactive Digital Arts

SA 4, due Wed, Jan 14

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

  1. A ball starts off at the upper left.
  2. Every frame, the ball moves one step to the right, and a random amount, between -1 and 1, up or down.
  3. Every frame, the ball has a random size (same for its width and height), between 1 and 10 units.
  4. The ball is drawn in white, and the screen slowly fades away to black.
  5. When the mouse is pressed, the ball starts back on the left at a random y position.

Avoid the use of magic numbers; in particular, make sure that the sketch will still work properly if the size is changed.

screenshot[applet]

As always, turn in the zipfile on Blackboard, as SA 4 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.