Hey I was wondering about how I would add more balls to the program over time and how to make the program freeze or stop if the image touches a ball. thanks!
int numBalls = 1;
float spring = .05;
float gravity = 0.1;
float friction = -1;
Ball[] balls = new Ball[numBalls];
PImage b;
int timer=0;
int elapsed=0;
int del=2000;
void setup()
{
size(1000, 400);
timer=millis();
noStroke();
smooth();
for (int i = 0; i < numBalls; i++) {
balls[i] = new Ball(random(width), random(height), random(20, 40), i, balls);
b = loadImage("thing.gif");
}
}
void draw()
{
noCursor();
background(0);
for (int i = 0; i < numBalls; i++) {
balls[i].collide();
balls[i].move();
balls[i].display();
}
}
class Ball {
float x, y;
float diameter;
float vx = 0;
float vy = 0;
int id;
Ball[] others;
Ball(float xin, float yin, float din, int idin, Ball[] oin) {
x = xin;
y = yin;
diameter = din;
id = idin;
others = oin;
elapsed=millis()-timer; // measure elapsed time
if (elapsed>del*1){