import processing.opengl.*; Physics physics; Particle p; Line toMouse; Point m; int timer = 0; void setup(){ size(400, 400); physics = new Physics(); p = physics.addParticle(100, 100); Particle temp0 = p; for(int i = 0; i < 100; i++){ Particle temp1 = physics.addParticle(100+(i+1)*1, 100+(i+1)*1); Spring s = physics.addSpring(temp0, temp1); s.stiffness = 0.1; temp0 = temp1; } m = new Point(mouseX, mouseY); toMouse = new Line(p, m); smooth(); } void draw(){ background(255); physics.verlet(); physics.springs(); if(mousePressed){ m.setPosition(mouseX, mouseY); toMouse.updateLine(); p.addVelocity(toMouse.dx, toMouse.dy); } //physics.drawSprings(); //physics.drawParticles(); for(int i = 0; i < physics.s.size(); i++){ strokeWeight(10 * sin((PI / physics.s.size()) * i)); Spring temp = (Spring)physics.s.get(i); line(temp.a.x, temp.a.y, temp.b.x, temp.b.y); } }