So in my game there are invisible walls but when I fly down I get stuck in them and only can move left and right after that, her is the code.
public void move (String direction) { if(direction.equals("Up")) { if(getY()+speed<550) { setLocation(getX(), getY() - speed); } } if(direction.equals("left")) { if(getX()-speed<560) { setLocation(getX() - speed, getY()); } } if(direction.equals("down")) { if(getY()-speed<550) { setLocation(getX(), getY() + speed); } } if(direction.equals("right")) { if(getX()+speed<500) { setLocation(getX()+speed, getY()); } } }