1 lines, no comments ยท 356 tokens, written in 2 seconds for $0.0006


1  let particles = []; function setup() { createCanvas(windowWidth, windowHeight); for (let i = 0; i < 100; i++) { particles.push(new Particle()); } } function draw() { background(10, 15, 25, 50); for (let p of particles) { p.update(); p.show(); } } class Particle { constructor() { this.pos = createVector(random(width), random(height)); this.vel = p5.Vector.random2D().mult(random(1, 3)); this.color = color(random(100, 255), random(100, 255), 255); } update() { let mouse = createVector(mouseX, mouseY); let dir = p5.Vector.sub(mouse, this.pos); dir.setMag(0.2); this.vel.add(dir); this.vel.limit(5); this.pos.add(this.vel); if (this.pos.x < 0 || this.pos.x > width) this.vel.x *= -1; if (this.pos.y < 0 || this.pos.y > height) this.vel.y *= -1; } show() { noStroke(); fill(this.color); ellipse(this.pos.x, this.pos.y, 8); } }