View Single Post
  #5  
Old 07-20-2010, 08:16 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
otoh if you know the destination you can just take the vector to there, normalise it and then multiply it with how far you want to move

distx = 32 - player.x;
disty = 32 - player.y;
sqrtdist = sqrt(distx^2 + disty^2);
dx = r * distx / sqrtdist;
dy = r * disty / sqrtdist;
Reply With Quote