I am new to greenfoot. I am creating a maze game on greenfoot. At the moment my character goes through the walls but i would like him to stop when he hits the wall.
i have this code in the actors bit:
public void move() {
if (canSee (wall.class))
{
if (getRotation()== 270)//north 3
setLocation(getX(), getY() +8);
if (getRotation() == 90) //south 1
setLocation(getX(), getY()-8);
if (getRotation() == 0)//east 0x
setLocation(getX() - 8, getY());
if (getRotation() == 180)//west 180
setLocation (getX() + 8, getY());
}
have i missed something obvious?