//Worms monster sketch //Gabe Graham 4/1/09 //Worms move toward mouse unless a button is pressed, then they move away //Array of worms Worm[] worm; int nWorms = 200; //number of worms void setup() { size(800,600,P2D); noSmooth(); frameRate(30); //initialize monters with random parameters worm = new Worm[nWorms]; for(int i=0; i0; i--){ x[i]=x[i-1]; y[i]=y[i-1]; } //get angle to target angle=atan2((ytarget-y[0]),(xtarget-x[0]))+dsteer; if (mousePressed==true) angle=PI+angle; //reverse direction if mouse pressed //update position of head x[0]+=speed*cos(angle); y[0]+=speed*sin(angle); //keep within bounds if (x[0]>width) x[0]=width; if (x[0]<0) x[0]=0; if (y[0]>height) y[0]=height; if (y[0]<0) y[0]=0; } //draw worm void draw() { fill(0); for(int i=0; i