hello, i’m having some trouble constricting the box space that triggers a change in visuals. i’ve drawn an outline of the area i want the visuals/mouse to change within. as the cursor moves out of this box, it should return to normal as the conditions become false. it does this correctly past the bottom and right sides of the box, but it changes too soon near the origin in the top left corner.
link to preview: https://editor.p5js.org/georg2a/present/kIcojHyUF
thanks to anybody who takes the time to read/respond to this!
let deer;
let love;
let dx;
let dy;
let dSize=180;
let overdBox=false;
let dlocked=false;
function preload(){
deer = loadImage("love.gif");
love = loadImage("deer.gif");
}
function setup() {
imageMode(CENTER);
//rectMode(CENTER);
createCanvas(600, 600);
dx = 200;
dy = 100;
}
function draw() {
background(0);
image(deer, width/2,height/2,600,600);
if (
mouseX > dx - dSize &&
mouseX < dx + dSize &&
mouseY > dy - dSize &&
mouseY < dy + dSize
) {
overdBox=true;
if (!dlocked) {
//deer.reset();
image(love,width/2,height/2,600,600);
}
}
else {
//love.reset();
image(deer,width/2,height/2,600,600);
overdBox=false;
}
//noStroke();
noFill();
square(dx,dy,dSize);
// square(100,100,dSize);
;
if (overdBox == true){
cursor(HAND);
} else {
cursor(ARROW);
}
}