import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; import netscape.javascript.*; import javax.comm.*; import javax.sound.midi.*; import javax.sound.midi.spi.*; import javax.sound.sampled.*; import javax.sound.sampled.spi.*; import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.sax.*; import javax.xml.transform.stream.*; import org.xml.sax.*; import org.xml.sax.ext.*; import org.xml.sax.helpers.*; public class example7 extends BApplet {PSystem ps;

Particle p1;

void setup() {
  size(500,500);
  ps = (PSystem)loadPlugin("PSystem");
  
  Particle p2 = null;
  
  ps.defaultSpringRestLength = 5;
  ps.defaultSpringStrength = 0.2f;
  
  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.2f);

}

void loop() {
  background(0xff99CCCC);
  p1.setPos(mouseX, mouseY, 0);
  ps.draw();
}}