1 lines, no comments ยท 339 tokens, written in 2 seconds for $0.0005


1  let circles = []; function setup() { createCanvas(windowWidth, windowHeight); for (let i = 0; i < 20; i++) { circles.push(new Circle()); } } function draw() { background(30, 30, 50); for (let c of circles) { c.update(); c.display(); } } function mousePressed() { for (let c of circles) { c.vel.mult(-1); } } class Circle { constructor() { this.pos = createVector(random(width), random(height)); this.vel = p5.Vector.random2D().mult(random(2, 5)); this.r = random(20, 50); this.color = color(random(255), random(255), random(255), 150); } update() { 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; } display() { fill(this.color); noStroke(); ellipse(this.pos.x, this.pos.y, this.r * 2); } }