xxxxxxxxxx
76
let stars = [];
let numStars = 200;
function setup() {
createCanvas(700, 700);
for(let i = 0; i < numStars; i = i + 1) {
stars.push(new Stars(random(width),random(height/1.5),1,255));
}
}
function draw() {
background (30);
for(let i =0; i < stars.length; i = i + 1) {
stars[i].update();
}
cityScape (50,50,50,50)
}
function cityScape () {
fill (255, 239, 170,random (200,210));
noStroke ();
ellipse (width/2,700,700,500);
fill (247, 226, 138,random (150,155));
ellipse (width/2,700,800,600);
fill (252, 192, 80,random (100,105));
ellipse (width/2,700,850,700);
fill(252, 154, 80,random (50,55));
ellipse (width/2,700,900,800);
fill (0);
rect (10,650,30,50);
rect (50,550,100,200);
rect (155,450,140,350);
rect (250,600,140,100);
rect (400,500,50,300);
rect (455,500,50,300);
rect (520,300,100,400);
rect (630,600,70,100);
}
class Stars {
constructor (x,y,r,c) {
this.x = x;
this.y = y;
this.r = r;
this.c = c;
}
update () {
fill (this.c, random (200))
circle (this.x,this.y,this.r);
this.x = this.x + random (-0.1,0.1);
}
}