I've figured out how to make my class (a rocket) not go through walls when pressing left, right, and up,
my problem is when I press the "down" key, the rocket will pass through the wall and move to the nearest open space.
Any help would be appreciated, Thank you!
public void checkKeyPressed()
{
setRotation(90);
if (Greenfoot.isKeyDown("up"))
{move(-1); }
if (canSee(Wall.class))
{
move(1);
}
if (Greenfoot.isKeyDown("down"))
{move(1); }
setRotation(0);
if (canSee(Wall.class))
{
move(-1);
}
if (Greenfoot.isKeyDown("left"))
{move(-1); }
if (canSee(Wall.class))
{
move(1);
}
if (Greenfoot.isKeyDown("right"))
{move(1); }
if (canSee(Wall.class))
{
move(-1);
}
}
}

