I have programmed most of the game now but I stucked on how to let the pacman stop at a wall.
I have these so far:
public void act()
{
if(direction == 0)
{
setLocation(getX()+1, getY());
}
if(direction == 1)
{
setLocation(getX()-1, getY());
}
if(direction == 2)
{
setLocation(getX(), getY()+1);
}
if(direction == 3)
{
setLocation(getX(), getY()-1);
}
movement();
abilityToEat();
}
public boolean foundWalls()
{
Actor walls = getOneObjectAtOffset(10, 10, Walls.class);
if(walls != null) {
return true;
}
else {
return false;
}
}
I am wondering if my "foundWall" method is right, in addition of how to use it if it was correct.
Thank you.

