xxxxxxxxxx
28
function setup() {
createCanvas(320, 240);
background(255, 100, 100);
noStroke();
fill(100,255,100);
rect(0,0, 160, 240);
}
var displaytxt;
function draw() {
background(255, 100, 100);
noStroke();
fill(100,255,100);
rect(0,0, 160, 240);
displaytxt = whatside(); // saving what is returned into a variable
text(displaytxt, 170, 120);
}
function whatside() {
if (mouseX > 160) {
return "RIGHT";
} else {
return "LEFT";
}
}