slatenails

aproxdistance in acs

Aug 20th, 2013
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. // ============================================================================
  2. // [Dusk] AproxDistance: Doom's P_AproxDistance, converted to ACS.
  3. // It's faster, but less accurate than distance().
  4. function int AproxDistance (int t1, int t2) {
  5. int dx = abs (GetActorX (t1) - GetActorX (t2));
  6. int dy = abs (GetActorY (t1) - GetActorY (t2));
  7.  
  8. if (dx < dy)
  9. return dy + (dx / 2);
  10.  
  11. return dx + (dy / 2);
  12. }
Advertisement
Add Comment
Please, Sign In to add comment