xxxxxxxxxx
42
let speed;
let y;
let x;
let w;
let vertical = 0;
function setupStick(){
vertical = random([0, 1]);
speed = random(3, 15);
y = vertical ? height : random(height);
x = !vertical ? 0 : random(width);
w = random(50);
}
function setup() {
createCanvas(windowWidth, windowHeight);
background('#fff');
noStroke();
fill('#000');
setupStick();
}
function draw() {
rect(x, y, w, speed-1);
if(vertical){
if(y <= 0){
setupStick();
}else{
y -= speed;
}
}else{
if(x >= width){
setupStick();
}else{
x += speed;
}
}
}