class Thingy { private PVector last_loc; public PVector loc; public PVector acc; public PVector vel; public float mass; public boolean dead = false; float grayscale = 0; float age = 0; Thingy() { this.acc = new PVector(0,0); this.vel = new PVector(0,0); this.loc = new PVector(0,0); this.last_loc = new PVector(0,0); this.mass = 0; } Thingy(PVector initial_loc) { this.acc = new PVector(0,0); this.vel = new PVector(0,0); this.loc = initial_loc.get(); this.last_loc = initial_loc.get(); this.mass = random(0,1) * 1000 + 700; //println("mass:" + this.mass); this.grayscale = 255;//map(random(1,5),1,5,0,255); } public void die() { dead = true; } public void live() { dead = false; age = 0; } void applyForce(PVector force) { force.div(this.mass); this.acc.add(force); } void update() { if (this.loc.x > width || this.loc.x < 0 || this.loc.y > height || this.loc.y < 0) { die(); } else { this.vel.add(this.acc); this.loc.add(this.vel); this.vel.mult(0.95); this.age++; } } void display() { if (!dead) { strokeWeight( constrain(map(this.loc.z,-1,8,0.5,0.8),0,1.2)); stroke(map(this.loc.z,-1,200,10,255));// noFill(); float side = constrain(map(this.loc.z,-1,3,2,4),2,4); line(this.loc.x - side,this.loc.y,this.loc.x + side,this.loc.y); line(this.loc.x,this.loc.y - side,this.loc.x,this.loc.y + side); this.last_loc = this.loc.get(); this.acc.mult(0); } } }