The enemy must move horizontally on one line, and after picking up the object, return to the n-th position and start moving vertically as well from one corner to another at these coordinates? How i can make it?
public void moveAround(){
if (isAtEdge()){
getImage().mirrorHorizontally();
direction = -direction;
}
setLocation(getX() + 1*direction, getY()); // setLocation(getX(), getY() 1*direction); if you want it move vertically
}