xxxxxxxxxx
29
let stars = [];
function setup() {
createCanvas(400, 400);
for (
let i = 0; i < 100; i = i+1){
stars.push(new Star(random(400), random (400), 5));
}
}
function draw() {
background(220);
for(
let i = 0; i < stars.length; i = i+1)
{ stars[i].update();
}
}
class Star{
constructor(x,y,s){
this.x = x;
this.y = y;
this.s = s;
}
update(){
ellipse(this.x,this.y,this.s,this.s);
}
}