1 lines, no comments ยท 2,655 tokens, written in 27 seconds for $0.032


1  let particles=[]; function setup(){createCanvas(windowWidth,windowHeight); for(let i=0;i<200;i++){particles.push(new Particle(random(width),random(height)));} background(10); noStroke();} function draw(){background(10,40); let m=createVector(mouseX||width/2,mouseY||height/2); for(let p of particles){p.attract(m); p.update(); p.show();}} class Particle{constructor(x,y){this.pos=createVector(x,y); this.vel=p5.Vector.random2D(); this.acc=createVector(); this.c=color(random(150,255),random(50,150),random(255));} attract(t){let f=p5.Vector.sub(t,this.pos); let d=constrain(f.mag(),10,100); f.setMag(400/(d*d)); this.acc.add(f);} update(){this.vel.add(this.acc); this.vel.limit(6); this.pos.add(this.vel); this.acc.mult(0);} show(){fill(this.c); circle(this.pos.x,this.pos.y,5);}} function windowResized(){resizeCanvas(windowWidth,windowHeight);}