Source code

//number of balls increased to the extreme

int MAX=9000;

//global variables

int[] xspeed = new int[MAX];

int[] yspeed = new int[MAX];

int[] x = new int[MAX];

int[] y = new int[MAX];

int[] r = new int[MAX];

void setup() {

size(400,400); //size

//arrays

for (int i = 0; i < MAX; i++) {

xspeed[i] = (int)(random(-5,25));

yspeed[i] = (int)(random(0,-100)); //vertical accent

x[i] = width/2;

y[i] = height/1;

r[i] = 50;

}

}

void loop() {

background(85); //background

ellipseMode(CENTER_DIAMETER); //ellipse

noStroke();

for (int i = 0; i < MAX; i++) {

fill(555,70,30); //color

ellipse(x[i],y[i],r[i],r[i]);

//radius always decreases back to 5 if it's bigger

if (r[i] > 5) { //size of the individual balls that make up the mass

r[i]--;

}

//adjust x,y based on speed

x[i] = x[i] + xspeed[i];

y[i] = y[i] + yspeed[i];

//bouncing

if ((x[i] > width) ||(x[i] < 0)) {

xspeed[i] = xspeed[i] * -1;

r[i] = 10; //adjust radius when bouncing

}

if ((y[i] > height)|| (y[i] < 0)) {

yspeed[i] = yspeed[i] *- 1;

r[i] = 50;

}

}

}

}

Built with Processing