xxxxxxxxxx
46
var drops = [];
let pg;
function setup() {
createCanvas(windowWidth, windowHeight);
pg = createGraphics(windowWidth, windowHeight);
for (var i = 0; i < 200; i++) {
drops[i] = new Drop();
}
}
function draw() {
clear();
pg.fill(255, 255, 0);
pg.ellipse(mouseX, mouseY, 100, 100);
// pg.clear();
// pg.background(0,0);
pg.fill(0, 10);
pg.rect(0, 0, width, height);
for (var i = 0; i < 200; i++) {
drops[i].show();
drops[i].update();
}
image(pg, 0, 0);
}
function Drop() {
this.x = random(0, width);
this.y = random(0, -height);
this.show = function () {
pg.noStroke();
pg.fill(112, 182, 234);
pg.ellipse(this.x, this.y, 2, 10);
};
this.update = function () {
this.speed = random(5, 15);
this.gravity = 0.85;
this.y = this.y + this.speed * this.gravity;
if (this.y > height) {
this.y = random(0, -height);
}
};
}