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.
1 2 3 4 5 6 7 8 | public void act() { die(); setLocation(getX(), getY() - 2 ); if (isTouching(wallT. class )) { turn ( 180 ); setLocation(getX(), getY() + 2 ); } } |