Advertisement
Flip

targeting

Dec 3rd, 2013
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         else {
  2.             var r:MovieClip = MovieClip(parent);
  3.             dist = Math.sqrt((target.y - y) * (target.y - y) + (target.x - x) * (target.x - x));
  4.             var smod:int = dist/10;
  5.             var xdif:int = (target.x - target.lx) * smod;
  6.             var ydif:int = (target.y - target.ly) * smod;
  7.             if (smod > target.eta) {
  8.                 var wp1:MovieClip = r.waypoints[target.c];
  9.                 var wp2:MovieClip = r.waypoints[target.c+1];
  10.                 var smod2:int = target.speed * (smod - target.eta);
  11.                 cx = wp2.x - wp1.x;
  12.                 cy = wp2.y - wp1.y;
  13.                 if (cx != 0) { cx = (cx > 0) ? wp1.x + (1 * smod2) : wp1.x + (-1 * smod2); }
  14.                 else { cx = wp2.x; }
  15.                 if (cy != 0) { cy = (cy > 0) ? wp1.y + (1 * smod2) : wp1.y + (-1 * smod2); }
  16.                 else { cy = wp2.y; }
  17.             }
  18.             else {
  19.                 cx = target.x+xdif;
  20.                 cy = target.y+ydif;
  21.             }
  22.             dist = Math.sqrt((cy - y) * (cy - y) + (cx - x) * (cx - x));
  23.             speed = dist/smod;
  24.             angle = Math.atan2(cy - y, cx - x);
  25.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement