Skip to content

Instantly share code, notes, and snippets.

@patricoferris
Created February 20, 2018 13:15
Show Gist options
  • Save patricoferris/f9c11ad33ed86e659d8e170d8ea69a18 to your computer and use it in GitHub Desktop.
Save patricoferris/f9c11ad33ed86e659d8e170d8ea69a18 to your computer and use it in GitHub Desktop.
function Particle(x, y, color){
this.pos = createVector(x + random(-10, 10), y + random(-10, 10));
this.vel = createVector(floor(random(-1, 1))*noise(this.pos.x), -noise(this.pos.y)*7);
this.alpha = 255;
this.r = random(170, 255);
this.g = random(10, 255);
this.b = random(0, 100);
this.update = function(){
this.pos.add(this.vel);
this.alpha -= 5;
}
this.show = function(){
noStroke();
fill(this.r, this.g, this.b, this.alpha);
rect(this.pos.x, this.pos.y, 5, 5);
}
this.dead = function(){
if(this.alpha < 0){
return true;
}else{
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment