xxxxxxxxxx
45
let xPosition=0;
let xSpeed=12;
function setup() {
createCanvas(400, 400);
noStroke();
rectMode(CENTER);
frameRate(10);
background(250);
}
function draw() {
//background(255);
fill(random(255),255,0);
rect(xPosition,width/2,100,100);
//
fill(255,random(255),255);
rect(xPosition,width/4,random(50,100),100);
//
fill(random(255),255,255);
rect(xPosition,width-(width/4),random(50,100),100);
xPosition += xSpeed;
if(xPosition > width || xPosition <0){
xSpeed *= -1;
}
}