I am try to make an AI for an enemy but for some reason the enemy only travels up and left. This is the moving code:
public void ovalMove()
{
int RandomMoveX = Greenfoot.getRandomNumber(1);
int RandomMoveY = Greenfoot.getRandomNumber(1);
if(RandomMoveX == 0 && !WallL())
{
setLocation(getX()-4, getY());
}else if(RandomMoveX == 1 && !WallR()){
setLocation(getX()+4, getY());
}
if(RandomMoveY == 0 && !Ceiling()){
setLocation(getX(), getY()-4);
}else if(RandomMoveY == 1 && !Ground()){
setLocation(getX(), getY()+4);
}
}
