This was a test I just failed and I don,t have a clue on what I was suppose to do
public class Ball extends Actor { private int oldX ; private int newX ; public Ball() { oldX = 0; newX = 0; } public void act() { if (Greenfoot.mousePressed(this)){ int deltaX = Greenfoot.getRandomNumber(100); // You need to store the store the current location of the ball at oldX // that newX can be obtained based on it. newX = oldX + deltaX; } if (oldX != newX){ // The ball keeps moving towards newX only when it is not there yet. // As soon as it reaches newX, it stops moving. setLocation(getX()+1, getY()); } } }