0

I'm newbie in java, can you help me to this code.
the image needs to move diagonally

public void actionPerformed(ActionEvent e) {
        x += 3;
        if (x > 600) {
            y = random.nextInt(600);
            x = random.nextInt(-45);
            star.setX(x);
            star.setY(y);
        }
3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by NormR1
1

the image needs to move diagonally

Does that imply a special way that the x and y values should change from one drawing of the image to the next drawing?
Should there be a relationship between the x,y for one position and the x,y for the next position? If so, what is the equation to compute a new x,y from an old x,y?

Edited by NormR1: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.