Check if a player's position has changed since last update?

Hello all,

I was wondering how you could check if a “player” has changed his position since the last paint update has been called.

The code I have now just doesn’t seem to do it:


public void move() {
	oldX = x;
	oldY = y;
	x += speedX;
	y += speedY;
}
public boolean hasMoved() {
        int pX = oldX - x;
	int pY = oldY - y;
	if (pX < 0 || pX > 0 || pY < 0 || pY > 0)
		return true;
	return false;
}

move() get’s called every time the player presses up, down, right or left.

Any tips would be great!

public void move() {
	oldX = x;
	oldY = y;
	x += speedX;
	y += speedY;
}
public boolean hasMoved() {
//only changed here
       if(oldY!=y||oldX!=x) return true;
	return false;
}

glad to help

D’Oh, thanks!