class Particle { float x, y,z, vx, vy,vz, a, grav, bouncy, xdrag,ox,oy,dx,offx; float age,life,noffset; float agelimit = 500; Particle(float xpos, float ypos, float area) { x = xpos; offx = random(-100,100); y = ypos; ox = xpos; oy = ypos; a = area; age = 0; vx = random(-8,8); vy = random(-8,8); grav = random(.1,.4); bouncy = random(-.7); xdrag = random(.5,.9); noffset =0; } void offset() { noffset+=1000; } void pulse() { a = (in.left.get(2)*200)+10; } void move() { noffset+=.04; if(age < agelimit) { age++; } // life = age/agelimit; //println(life); //vy+=((grav*.1)*(1-life)) ; vx*=xdrag; vy*=xdrag; vx+=(noise(x/y+noffset*3,y/x+noffset*3)-.475)*1.5; vy+=(noise(y/x+noffset*3,x/y+noffset*3)-.475)*1.5; // vz+=(noise(y/x+noffset,y/x+noffset)-.5)*.01; // vx+=noise(x*.01+noffset,this.y*.01+noffset)-.5; //vy+=noise(this.y*.01+noffset,this.x*.01+noffset)-.45; x+=vx; y+=vy; z+=vz; //a = (in.left.get(2)*200)+10; if(y > height) { y = height-1; vy*=bouncy; vx+=random(-3,3); } if(y < 0) { y = 0; vy*=bouncy; } if(x > width) { x = width; vx*=bouncy; } if(x < 0) { x = 0; x*=bouncy; } } //-----------------------slide------------------------------ void slide() { x-=.2; ox-=.2; pushMatrix(); translate(x,y,0); noStroke(); fill(0,10); rectMode(CENTER); rect(0,0,a,a); noFill(); popMatrix(); if(x < 0) { dx = ox -x; x = width; ox = x+dx; } } void display() { pushMatrix(); translate(x,y,0); noStroke(); fill(0,10); rectMode(CENTER); rect(0,0,a,a); noFill(); popMatrix(); stroke(0,20); line(x,y,ox,oy); line(x,y,ox+offx,oy); } }