atan( dy/dx )
// Cursor's in Quadrant II with respect to chaser object.
else if( dx<0 && dy>=0 ) angle = Math.atan( dy/dx ) + Math.PI
// Cursor's in Quadrant III with respect to chaser object.
else if( dx<0 && dy<0 ) angle = Math.atan( dy/dx ) + Math.PI
// Cursor's in Quadrant IV with respect to chaser object.
else if( dx>0 && dy<0 ) angle = Math.atan( dy/dx ) + 2*Math.PI
} else {
// Cursor is sitting right on the positive y-axis.
if( dy>0 ) angle = Math.PI/2
// Cursor is sitting right on the negative y-axis.
else angle = 1.5*Math.PI
Compute the fractional move toward the cursor along the x-axis and the y-axis.
xstep
|