Пример #1
0
  /** Update all of the Ball's and draw them */
  public void update() {

    if (balls.size() != 0) {

      for (int i = 0; i < balls.size(); i++) {
        Ball b = (Ball) balls.get(i);
        b.update();
        b.attract = kelly;
        b.drawBall();
      }
    }
  }
Пример #2
0
  /** Add a ball to the ArrayList at current mouse position */
  public void addBall() {

    // Store current mouse position
    x1 = mouseX;
    y1 = mouseY;
    // Get a random offset for the ball
    int xDiff = (int) random(-10, 10);
    int yDiff = (int) random(-10, 10);
    // Add the mouse's (x,y) and the random offset
    int x = mouseX + xDiff;
    int y = mouseY + yDiff;
    // Create new ball
    Ball b = new Ball(x, y, ballSize);
    b.STEM = stems;
    b.attract = kelly;
    balls.add(b);
  }