← IAT 806

Lab 05 — Classes, This & Methods

The balls do weird things.

Notes

Methods in the Ball class:

  1. show(): draws the ball as a circle in its own color, at its current position and size.
  2. move(): nudges the ball a few pixels in a random direction, so it wanders.

Updated methods:

  1. changeSize(minR, maxR): randomly grows or shrinks the ball a little, constraining its size between minR and maxR.

New methods:

  1. updatePosition(x, y): moves the ball to a new spot and resets its falling speed.
  2. swirl(mouseX, mouseY): moves the ball around in a circle centered on the mouse.
  3. fall(): pulls the ball down with gravity and bounces it off the bottom of the canvas, a bit lower each time.

Interactions:

View the Codebase