I tried:
PHP Code:
temp.dx = DragItem.x - player.x;
temp.dy = DragItem.y - player.y;
player.dir = getdir(temp.dx, temp.dy);
It only works when the DragItem is far away from the player.
EDIT: SOLVED!!!
PHP Code:
temp.sx = screenx(player.x,player.y);
temp.sy = screeny(player.x,player.y);
temp.dx = DragItem.x - temp.sx;
temp.dy = DragItem.y - temp.sy;
player.dir = getdir(temp.dx, temp.dy);
This fixed it.