Mover[ ]movers = new Mover[num];
for (int i=0; i<movers.length; i++) {
movers[i] = new Mover(random(0.5, 2), random(width), random(height));
for (int i=0; i<movers.length; i++) {
PVector f1 = a.attract(movers[i]);
PVector f2 = a2.attract(movers[i]);
PVector f = PVector.add(f1, f2);
save(random(12344) + ".png");
location = new PVector(random(width), random(height));
float mov = map(sin(theta),-1,1,-150,150);
ellipse(location.x+mov, location.y+mov, mass*2, mass*2);
PVector attract(Mover m) {
PVector force = PVector.sub(location, m.location);
float distance = force.mag();
distance = constrain(distance, 5.0, 50.0);
float strength = (G*mass*m.mass)/(distance*distance);
PVector location, velocity, acceleration;
Mover(float m, float x, float y) {
location = new PVector(x, y);
velocity = new PVector(random(-4, 4), random(-4, 4));
acceleration = new PVector(0, 0);
velocity.add(acceleration);
ellipse(location.x, location.y, sz, sz);
void applyForce(PVector force) {
PVector f = PVector.div(force, mass);
for (int i=0; i<movers.length; i++) {
float distance = dist(location.x, location.y, o.location.x, o.location.y);
if (distance>0 && distance<100) line(location.x, location.y, o.location.x, o.location.y);
if (location.x > width-sz/2 || location.x < sz/2) velocity.x *= -1;
if (location.y > height-sz/2 || location.y < sz/2) velocity.y *= -1;