Guy guy; ArrayList treasures = new ArrayList(); void setup() { size(200, 200); // Size should be the first statement noStroke(); // Set line drawing color to white frameRate(30); for (int i=0;i guysToRemove = new ArrayList(); for(Guy t : treasures) { t.move(); t.draw(); float dist = mag(t.x-guy.x,t.y-guy.y); if(dist < 20){ guysToRemove.add(t); } } treasures.removeAll(guysToRemove); } class Guy{ float x = 100; float y = 100; float xspeed = .1,yspeed = .1; boolean player; float gx, gy; Guy(boolean main){ if(!main){ x = random(200); y = random(200); } player = main; gx = random(200); gy = random(200); } void draw(){ float bright = closest * 3; if(player){ fill(bright,0,0,40); float r = bright / 10; // ellipse(x,y,r,r); } else { fill(0,bright,0,200); // ellipse(x,y,10,10); } } float closest; void move(){ closest = 400; int nearest=-1; for (int p=0;p200) {x = 200; xspeed *= .5;} if(y>200) {y = 200; yspeed *= .5;} float MAX = 3; if(sqrt(pow(xspeed,2)+pow(yspeed,2)) > MAX){ float wa = atan2(yspeed,xspeed); xspeed = MAX * cos(wa); yspeed =MAX * sin(wa); } } } ArrayList points=new ArrayList(); class Attractor { public float x; public float y; public float dx; public float dy; public Attractor() { this.x=random(200); this.y=random(200); this.dx=-random(-1,1); this.dy=-random(-1,1); } public void move() { if(mousePressed){ /* if( x < mouseX){ dx += .15; } if( x > mouseX){ dx -= .15; } if( y < mouseY){ dy += .15; } if( y > mouseY){ dy -= .15; } */ } // move with wall bounce this.x+=this.dx; if (this.x<0) { x = 0; dx = abs(dx);} if (this.x>200) { x = 200; dx = -abs(dx);} this.y+=this.dy; if (this.y<0) { y = 0; dy = abs(dy);} if (this.y>200) { y = 200; dy = -abs(dx);} } public float distanceTo(float xx,float yy) { return dist(xx,yy,this.x,this.y); } } float y = 100; int NUMATTRACTORS = 15; void doBackground(){ for (int x=0;x<200;x+=4) { for (int y=0;y<200;y+=4) { int nearest=0; float closest=1000.0; for (int p=0;p