PSystem ps;
Particle p1;
void setup() {
size(500,500);
ps = (PSystem)loadPlugin("PSystem");
Particle p2 = null;
ps.defaultSpringRestLength = 5;
ps.defaultSpringStrength = 0.2;
p1 = new Particle();
p1.setPos(100, height/2, 0);
p1.fix();
ps.addParticle(p1);
for (int i = 0; i < 10; i++) {
p2 = new Particle(100+i*20, height/2, 0);
ps.addParticle(p2);
ps.addSpring(p1, p2);
p1 = p2;
}
p2.fix();
ps.setGravity(0.2);
}
void loop() {
background(#99CCCC);
p1.setPos(mouseX, mouseY, 0);
ps.draw();
}
|