Hey,
I want to include an enemy in my game.
The Problem: the enemy is running into trees (most not, but sometimes) and so I'm searching for my fault - but haven't found it yet. The thing is, my enemy sometimes thinks that there is a tree e.g. to his right, but there isn't (I found this out by step-by-step controlling). Maybe you could help me, please? :)
This is the Code for treeRight (same for left, up and down (except for the names and the koordinates)):
public boolean treeRight() {
int x = getX();
int y = getY();
if(getObjectsAtOffset(x+1, y, tree.class) == null) {
return false;
}
else {
return true;
}
thank you a lot! :)