How can I make an actor move up and down at random heights while moving at a constant speed of 1.


// with these instance fields private int direction = -1; private int cycles = Greenfoot.getRandomNumber(75)+25; // using the 'move' method private void move() { setLocation(getX(), getY()+direction; cycles--; if (cycles == 0) { direction = -direction; cycles = Greenfoot.getRandomNumber(75)+25; } }