// run magnet simulation with gravity, drag, etc. Point history[]; int historyLen = 500; int curPoint = 0; boolean historyDone; Blob billy; void setup(){ size(500,600); background(255); billy = new Blob(40, 200); billy.vx = 6.0; historyDone = false; history = new Point[historyLen]; for (int i=0; i= height){ vy = 0 - vy; vy *= COLLISION_FRICTION; } } void update(){ handleGroundCollision(); px += vx; py += vy; while (px > width){ px -= width; } while (px < 0){ px += width; } } } //------------------------- class Blob extends PhysicalThing { float R; //radius Blob(float x, float y){ px = x; py = y; vx = vy = 0; R = 8; } void render(){ ellipseMode(CENTER_DIAMETER); stroke(0,0,0); fill(255, 200, 200); push(); translate(px, py); float ang = atan2 (vy, vx); rotateZ(ang + HALF_PI); float sqx = (R*2) + abs(vx) * 0.5; float sqy = (R*2) + abs(vy) * 0.5; ellipse(0, 0, sqx, sqy); pop(); } }