void keyPressed(){ things = new ArrayList(); background(255); thing = null; } ArrayListthings = new ArrayList(); Thing thing = null; float axs, ays; void setup(){ background(255); size(500,500); smooth(); noStroke(); } void draw(){ if(thing != null) { thing.draw(); } for(Thing t:things){ t.move(); t.draw(); } } void mousePressed(){ thing = new Thing(); } void mouseReleased(){ if(thing != null){ thing.release(); things.add(thing); } } void mouseDragged(){ if(thing != null){ thing.force(); } } float sz = 30; class Thing{ float x,y,xs,ys; color c; boolean free = false; Thing(){ c = color(random(255),random(255),random(255)); x = mouseX; xs = mouseX - pmouseX; y = mouseY; ys = mouseY - pmouseY; oldx = x; oldy = y; //xs *= -1; ys*= -1; } void release(){ free = true; } float G = .1; float oldx,oldy; void move(){ oldx = x; oldy = y; if(free){ //xs += map(250-x,0,200,0,1); //ys += map(250-y,0,200,0,1); if(x < 250) xs += G; if(y < 250) ys += G; if(x > 250) xs -= G; if(y > 250) ys -= G; x += xs; y += ys; } } void force(){ oldx = x; oldy = y; x = mouseX; y = mouseY; xs += mouseX - pmouseX ; ys += mouseY - pmouseY; xs *= .3; ys *= .3; stroke(c); strokeWeight(10); line(x,y,oldx,oldy); } void draw(){ if(free){ stroke(c); strokeWeight(10); line(x,y,oldx,oldy); } } }