direction doesnt matter.
as i said.. compare last x/y to current x/y every second..
PHP Code:
temp.distancex = abs(temp.ox - player.x);
temp.ox = player.x
for example..
I use ABS for because we want the absolute value (non negative number)... if u move to the right.. it will be a negative number.. move to the left it will be positive.. making it abs will make it always positive.