xxxxxxxxxx
29
let a,b,c,d,centerX,centerY;
function setup() {
createCanvas(600, 400);
a = width/4; // top/bottom left X
b = width/4*3; // top/bottom right X
c = height/4; // left/right top Y
d = height/4*3; // left/right bottom Y
centerX = width/2
centerY = height/2
}
function draw() {
background(220);
line(a, c, b, c);
line(b, c, b, d);
line(b, d, a, d);
line(a, d, a, c);
if(centerX < mouseX) a+=2
if(centerX < mouseX) b+=2
if(centerX > mouseX) a-=2
if(centerX > mouseX) b-=2
if(centerY < mouseY) c+=2
if(centerY < mouseY) d+=2
if(centerY > mouseY) c-=2
if(centerY > mouseY) d-=2
}