Hi guys, I'm just programming a game as a project. I'm planning to create my own RPG game. So there I am writing down in a monster class an algorithm that should check if the hero (Joe in my game) is near 300 pixels. So I wrote this :
The problem is, the monster considers the boolean joeIsNear as true only if he is on the upper left side of the monster itself... I can't solve this alone ^^ please help me !
public void checkIfJoeIsNear() { if (getX() - Joe.joeX < 300 && Joe.joeY - getY() < 300 && getX() - Joe.joeX > 0 && Joe.joeY - getY() > 0) {joeIsNear = true;} else {joeIsNear = false;} if (getX() - Joe.joeX < 300 && getY() - Joe.joeY < 300 && getX() - Joe.joeX > 0 && getY() - Joe.joeY > 0) {joeIsNear = true;} else {joeIsNear = false;} if (Joe.joeX - getX() < 300 && Joe.joeY - getY() < 300 && Joe.joeX - getX() > 0 && Joe.joeY - getY() > 0) {joeIsNear = true;} else {joeIsNear = false;} if (Joe.joeX - getX() < 300 && getY() - Joe.joeY < 300 && Joe.joeX - getX() > 0 && getY() - Joe.joeY > 0) {joeIsNear = true;} else {joeIsNear = false;} }