Danpost do you mind explaining that bit of code?
private int dirY = 1; // for the current direction ( 1 : up ; -1 : down) private int distY = 0; // for steps taken in current direction public void act() { setLocation(getX(), getY()+dirY); // move in direction distY = (distY+1)%5; // increment step count (with wrap: zeroes when incremented to 5) if (distY == 0) dirY = -dirY; // if 5 steps have been taken, reverse direction }