birdy1976_creative-coding/pac_man_goes_cannibal/pac_man_goes_cannibal.pde
/*
 * Creative Coding
 * * * * *
 * Pac-Man Goes Cannibal
 * * * * *
 * Interpretation by Martin VÃ¶geli
 * * * * *
 * Based on code by Indae Hwang and Jon McCormack
 *
 * This sketch shows the basics of classes and objects in Processing
 * It defines a class called "Ball" with member functions that move and display
 *
 */

// declare array of Balls
Ball theBalls[];
int numBalls = 99;

void setup() {
  size(640, 480);
  // initialise array and fill it with balls
  theBalls = new Ball[numBalls];
  for (int i = 0; i < numBalls; ++i) {
    float ballSize = constrain(20 + (randomGaussian() * 4), 1, 100);
    theBalls[i] = new Ball(random(width), random(height), ballSize);
    theBalls[i].randomiseDirection();
  }
  background(0);
}

void draw() {
  background(0);
  for (int i = 0; i < numBalls; ++i) {
    theBalls[i].move();
    theBalls[i].display();
    for (int j = 0; j < numBalls; ++j) {
      if (i != j) {
        theBalls[i].intersect(theBalls[j]);
      };
    }
  }
  saveFrame("####.png");
}