import traer.physics.*; ParticleSystem physics; Particle last; float yValue; int mouseCounter = 0; int mouse0 = mouseCounter%2; void setup() { size( 400, 400 ); background(255); fill( 255, 64 ); frameRate( 24 ); physics = new ParticleSystem(0.5, 0.001 ); ellipseMode( CENTER ); smooth(); cursor(CROSS); } void mouseReleased() { mouseCounter++; if (mouseCounter%2 == 0) { physics = new ParticleSystem(0.5, 0.001 ); } else { physics = new ParticleSystem(-0.5, 0.001 ); } } void draw() { yValue = mouseY; //println(mouseY/100); for ( int i = 0; i < 5; i++ ) { Particle p = physics.makeParticle( 1.0f, mouseX, mouseY, mouseY); p.setVelocity( random( -1, 1 ), random( -1, -1 ), 0 ); if ( last != null ) physics.makeSpring( p, last, 0.1f, 0.1f, 10 ); last = p; } physics.tick(); noStroke(); for ( int i = 0; i < physics.numberOfParticles(); ++i ) { Particle p = physics.getParticle( i ); if(mouseCounter%2 == 1){ //println(mouseCounter); fill(255); //physics = new ParticleSystem(-0.5, 0.001 ); // ellipse( p.position().x(), p.position().y(), 10, 10); // if ( p.age() > 30 ){ // p.kill(); } else if(mouseCounter%2 == 0){ //println(mouseCounter); //physics = new ParticleSystem(0.5, 0.001 ); fill( 0, 0,0,(255/(p.age()+1)*(yValue/400)) ); } ellipse( p.position().x(), p.position().y(), 4, 4); if ( p.age() > 30 ){ p.kill(); } if(p.age()>2){ ellipse( p.position().x(), p.position().y(), yValue/20, yValue/20); //println(mouseY/100); } } }