Created
February 20, 2018 13:15
-
-
Save patricoferris/f9c11ad33ed86e659d8e170d8ea69a18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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