I want to say that if the class "Ghost" contains the Image "picture1.png" the "Ghost"-class should move left and when the class contains the Image "picture2.png" it should move right somthing like that (I know it's wrong but i trief my best):
public void act()
{
if (setImage("picture1.png")&& !getOneObjectAtOffset( 4, 0, wall.class)&& !getOneObjectAtOffset (-4, 0, wall.class)&& getOneObjectAtOffset( 0, 4, wall.class)&& getOneObjectAtOffset( 0, -4, wall.class))
{
setLocation(getX()+4, getY());
}
if (setImage("picture1.png")&& !getOneObjectAtOffset( 4, 0, wall.class)&& !getOneObjectAtOffset (-4, 0, wall.class)&& getOneObjectAtOffset( 0, 4, wall.class)&& getOneObjectAtOffset( 0, -4, wall.class))
{
setLocation(getX()-4, getY());
}
}
