import traer.physics.*; Particle mouse, b, c; Particle[] others; ParticleSystem physics; PImage img; void setup() { size( 400, 400 ); framerate( 24 ); cursor( CROSS ); // sprite mask thing stolen from dan shiffman PImage msk = loadImage("texture.gif"); img = new PImage( msk.width, msk.height ); for ( int i = 0; i < img.pixels.length; i++ ) img.pixels[i] = color(255); img.mask(msk); imageMode(CORNER); tint( 255, 24 ); physics = new ParticleSystem( 0, 0.1 ); mouse = physics.makeParticle(); mouse.makeFixed(); others = new Particle[1000]; for ( int i = 0; i < others.length; i++ ) { others[i] = physics.makeParticle( 1.0, random( 0, width ), random( 0, height ), 0 ); physics.makeAttraction( mouse, others[i], 5000, 50 ); } } void draw() { mouse.moveTo( mouseX, mouseY, 0 ); physics.tick(); background( 0 ); for ( int i = 0; i < others.length; i++ ) { Particle p = others[i]; image(img,p.position().x()-img.width/2,p.position().y()-img.height/2); } }