import traer.physics.*; Particle mouse, topL, botL, topR, botR; Particle[] others; //ArrayList letters; ParticleSystem physics; PImage img_lg, img_sm, img_tny, tg; void setup() { size( 512, 512 ); frameRate( 24 ); cursor( CROSS ); // sprite mask thing stolen from dan shiffman img_lg = loadImage("turkey.tga"); img_sm = loadImage("turkey_sm.tga"); img_tny = loadImage("turkey_tiny.tga"); tg = loadImage("tg.tga"); // 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, 200 ); //letters = new ArrayList(); physics = new ParticleSystem( 0, 0.1 ); mouse = physics.makeParticle(); mouse.makeFixed(); topL = physics.makeParticle(); topL.makeFixed(); topL.moveTo(60,60,0); botL = physics.makeParticle(); botL.makeFixed(); botL.moveTo(height-60,60,0); topR = physics.makeParticle(); topR.makeFixed(); topR.moveTo(width-60,60,0); botR = physics.makeParticle(); botR.makeFixed(); botR.moveTo(width-60,height-60,0); others = new Particle[100]; int attract = 6000; for ( int i = 0; i < others.length; i++ ) { if (i >= 33) { if (i>=66) attract = 14000; else attract = 10000; } others[i] = physics.makeParticle( 1.0, random( 0, width ), random( 0, height ), 0 ); physics.makeAttraction( mouse, others[i], attract, 100 ); physics.makeAttraction( topL, others[i], attract/10, 60 ); physics.makeAttraction( botL, others[i], attract/10, 60 ); physics.makeAttraction( topR, others[i], attract/10, 60 ); physics.makeAttraction( botR, others[i], attract/10, 60 ); } attract = -10; for ( int i = 0; i < others.length; i++ ) for ( int j = 0; j < others.length; j++ ) { if (i >= 33) { if (i>=66) attract = -50; else attract = -25; } physics.makeAttraction( others[i], others[j], attract, 10 ); } background( 255 ); } void draw() { mouse.moveTo( mouseX, mouseY, 0 ); physics.tick(); fill(255,10); rect(0,0,width,height); image(tg,0,0); PImage img; Particle p; img = img_lg; for ( int i = 0; i < others.length; i++ ) { p = others[i]; if (i>=33) { if (i >= 66) img = img_sm; else img = img_tny; } if (p.position().x() < 0 || p.position().x() > width) p.addVelocity(-p.velocity().x(),0.0,0.0); if (p.position().y() < 0 || p.position().y() > height) p.addVelocity(0.0,-p.velocity().y(),0.0); image(img,p.position().x()-img.width/2,p.position().y()-img.height/2); } } /* void initLetters() { // make T Particle p; p = physics.makeParticle(2.0, 28,28,0); p.makeFixed(); letters.add(p); p = physics.makeParticle(2.0, 28,28,0); p.makeFixed(); letters.add(p); } */