My character needs to move up and down and needs to turn when it hits a wall. But it does some weird stuff when it hits the wall, I'm not sure what I'm doing wrong? Here's the code i've done.
  public void act() {
      die();
      setLocation(getX(), getY() - 2);
      if (isTouching(wallT.class)) { 
        turn (180);
        setLocation(getX(), getY() + 2);
      }
     }
          
        
  
