int gW, gH; node[] ns; int N = 8; //MUST be even!! void setup() { gW = 400; gH = 400; size(gW,gH); ns = new node[N]; for(int i=0; i maxv) vx = maxv; else if (vx < -maxv) vx = -maxv; if(vy > maxv) vy = maxv; else if (vy < -maxv) vy = -maxv; x = (x + vx) % gW; y = (y + vy) % gH; if (x < 0) x += gW; if (y < 0) y += gH; stroke(0); fill(78,97,108); ellipse(x,y,s,s); } void target(node n) { float dx = n.x - x; float dy = n.y - y; float sp = 20000; vx = vx + dx/sp; vy = vy + dy/sp; n.vx = n.vx - dx/sp; n.vy = n.vy - dy/sp; float d = abs(dx)+abs(dy); if(d < 120) { int a = (int)((230-78)*d/120); int b = (int)((230-97)*d/120); int c = (int)((230-108)*d/120); stroke(78+a,97+b,108+c); line(x,y,n.x,n.y); } } }