Last active
October 25, 2020 19:43
-
-
Save nickgs/104391ea388dde93610d27093533da64 to your computer and use it in GitHub Desktop.
Super Basic Particle System
This file contains hidden or 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 setup() { | |
createCanvas(windowWidth, windowHeight); | |
background("red"); | |
let pe = new ParticleEmitter(); | |
pe.draw(); | |
} | |
function draw() { | |
} | |
class Particle { | |
// we have a blueprint. | |
constructor(x, y) { | |
this.size = 10; | |
this.pos = createVector(x, y); | |
} | |
draw() { | |
ellipse(this.pos.x, this.pos.y, this.size); | |
} | |
} | |
class ParticleEmitter { | |
constructor() { | |
this.particles = []; | |
for(let i = 0; i <= 100; i++) { | |
this.particles[i] = new Particle(random(windowWidth), random(windowHeight)); | |
} | |
} | |
draw() { | |
for(let i = 0; i <= 100; i++) { | |
this.particles[i].draw(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment