xxxxxxxxxx
let x, y;
let leftWall, rightWall;
function setup() {
createCanvas(600, 600);
x = width/2;
y = 0;
leftWall = 0;
rightWall = width;
}
function draw() {
background(255);
y = mouseY;
leftWall = y/2;
rightWall = width-y/2;
//
// if (this.x > this.rightWall) {
// reverse direction!
// }
// if (this.x < this.leftWall) {
//
//
x = constrain(mouseX, leftWall, rightWall);
text("x: " + x, 50, 50);
text("leftWall: " + leftWall, 50, 100);
text("rightWall: " + rightWall, 50, 150);
if (y > height) {
y = 0;
}
ellipse(x, y, 20, 20);
}