xxxxxxxxxx
29
let x = 0;
let y = 0;
let incDec = true;
let mattincDec = true;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
//
if (incDec == true) {
x+=2;
}
if (incDec == false) {
x-=2;
}
if (x == 400) {
incDec = false;
}
if (x == 0) {
incDec = true;
}
rect(x, y, 50);
//test if x is greater than width or less than 0
}