xxxxxxxxxx
let particle = [];
let partNum = 0;
let partMax = 40; // Change this to the max amount of particles you want on the screen at once
function setup() {
createCanvas(windowWidth, windowHeight)
for (i = 0; i < 50; i++) {
particle.push(new Jitter())
}
}
function draw() {
background(50, 89, 100);
for (let i = 0; i < particle.length; i++) {
particle[i].move();
particle[i].display();
if (particle[i].x < width) {
splice(particle[i], 1)
} else if (particle[i].x > width) {
splice(particle[i], 1)
}
}
}
class Jitter {
constructor() {
this.x = random(-width, width);
this.y = random(-height, height);
this.diameter = random(10, 30);
this.speed = 10;
}
move() {
this.x += random(-this.speed, this.speed);
this.y += random(-this.speed, this.speed);
}
display() {
ellipse(this.x, this.y, this.diameter, this.diameter);
}
}