I am not sure why my code is not working. Specifically the section where i am trying to limit the players movements so he does not go out of bounds. This is an incomplete project that I’m trying to nail but i just can’t seem to get it right. Can anyone help?
This is a snippet of my code. My code is very hard to read without seeing the end result so I’ll just send the part that has the problem:
playerX = mouseX
playerY = mouseY
//sets the top border so that the character cannot exit the play area
//doesn’t work when i try it as when i move the mouse out of the boundaries the character still follows
if (mouseY < 67){
playerY = 67
} else {
playerY = mouseY
}
//sets the bottom border so that the character cannot exit the play area
if (mouseY > 535){
playerY = 535
} else {
playerY = mouseY
}
.
.
.
circle(playerX,playerY,40)
I have checked my code multiple times in case i accidentally set anything before these lines of code (or after) but I have not found any mistake. Please help?