xxxxxxxxxx
let num = 200;
let vecLocation = [];
let vecVelocity = [];
let snow;
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(20);
locationY = 0;
for (let i = 0; i < num; i++) {
vecLocation[i] = createVector(random(windowWidth), 0);
vecVelocity[i] = createVector(random(-10, 10), random(-10, 10));
}
}
function draw() {
fill(0, 34, 112);
rect(0, 0, windowWidth, windowHeight);
fill(230);
rect(0, windowHeight / 1.6, windowWidth, windowHeight /1.6);
fill(255);
rect(0, 0, windowWidth, 10);
noStroke();
let size = random(10,20);
for (let i = 0; i < num; i++) {
vecLocation[i].add(vecVelocity[i]);
ellipse(vecLocation[i].x, vecLocation[i].y, size, size);
fill(255);
if (vecLocation[i].x < 0 || vecLocation[i].x > width) {
vecVelocity[i].x = vecVelocity[i].x * -1;
fill(random(100,255), random(100,255), 0);
}
if (vecLocation[i].y < 0 || vecLocation[i].y > height) {
vecLocation[i].y = locationY;
}
}
}