int att_count = 300; int thing_count = 4; Thingy []things = new Thingy[thing_count]; Attracter []attracters = new Attracter[att_count]; boolean show_att = false; boolean fix_stroke = true; int back = 230; void setup() { size(800,450); smooth(); initme(); } void initme() { background(back); for (int i = 0; i < thing_count ; i++) { things[i] = new Thingy(new PVector(random(0,width),random(0,height))); things[i].vel = new PVector(random(0,width),random(0,height)); things[i].vel.normalize(); things[i].vel.mult(random(1,15)); } for (int i = 0; i < att_count ; i++) { attracters[i] = new Attracter(random(1,100)); attracters[i].activated = true; } println("---"); } void draw() { if ((millis() % 50) == 0) { noStroke(); fill(back,1); rect(0,0,width,height); } //background(255,5); for (int i = 0; i < att_count ; i++) { attracters[i].update(); for (int j = 0; j < thing_count ; j++) { PVector force = PVector.sub(things[j].loc, attracters[i].loc); force.normalize(); force.mult(-1 * attracters[i].strength); things[j].applyForce(force); things[j].update(); things[j].display(); } if (show_att) { attracters[i].display(); } } } void keyPressed() { if (key == 'p') { saveFrame("########.tif"); } if (key == ' ') { initme(); } if (key == 'a') { show_att = !show_att; println("show attractor:" + show_att); } if (key == 'x') { fix_stroke = !fix_stroke; } if (key == 'b') { if (back > 120) { back = 30; } else { back = 230; } initme(); } }