home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / roam-and-protect.swf / scripts / DefineSprite_378 / frame_1 / DoAction.as
Encoding:
Text File  |  2005-09-29  |  3.8 KB  |  193 lines

  1. function flight()
  2. {
  3.    var _loc1_ = _root;
  4.    myx = _X;
  5.    myy = _Y;
  6.    myw = _width * 0.5;
  7.    myh = _height * 0.5;
  8.    _loc1_.playerT = myy - myh;
  9.    _loc1_.playerB = myy + myh;
  10.    _loc1_.playerR = myx + myw;
  11.    _loc1_.playerL = myx - myw;
  12.    _loc1_.playerX = myx;
  13.    _loc1_.playerY = myy;
  14.    buty = "false";
  15.    butx = "false";
  16.    if(key.isdown(key.up))
  17.    {
  18.       chopper.jet.gotoAndPlay(2);
  19.       buty = "true";
  20.       if(ymove > -12)
  21.       {
  22.          ymove -= 2;
  23.       }
  24.       else
  25.       {
  26.          ymove = -12;
  27.       }
  28.    }
  29.    else if(key.isdown(key.down))
  30.    {
  31.       buty = "true";
  32.       if(ymove < 12)
  33.       {
  34.          ymove += 2;
  35.       }
  36.       else
  37.       {
  38.          ymove = 12;
  39.       }
  40.    }
  41.    if(direct > 0)
  42.    {
  43.       if(key.isdown(key.left))
  44.       {
  45.          butx = "true";
  46.          chopper.jet.gotoAndPlay(2);
  47.          if(xmove > -10)
  48.          {
  49.             xmove -= 3;
  50.          }
  51.          else
  52.          {
  53.             xmove = -10;
  54.          }
  55.          if(_X < 430)
  56.          {
  57.             _X = _X + 12;
  58.          }
  59.          if(chopper._rotation > -30)
  60.          {
  61.             chopper._rotation -= 5;
  62.             chopper.jet._rotation -= 5;
  63.          }
  64.       }
  65.       else
  66.       {
  67.          if(chopper._rotation < 0)
  68.          {
  69.             chopper._rotation += 5;
  70.             chopper.jet._rotation += 5;
  71.          }
  72.          if(key.isdown(key.right))
  73.          {
  74.             chopper._xscale *= -1;
  75.             chopper._rotation *= -1;
  76.             direct *= -1;
  77.          }
  78.       }
  79.    }
  80.    else if(key.isdown(key.right))
  81.    {
  82.       butx = "true";
  83.       chopper.jet.gotoAndPlay(2);
  84.       if(xmove < 10)
  85.       {
  86.          xmove += 3;
  87.       }
  88.       else
  89.       {
  90.          xmove = 10;
  91.       }
  92.       if(_X > 180)
  93.       {
  94.          _X = _X - 11;
  95.       }
  96.       if(chopper._rotation < 30)
  97.       {
  98.          chopper._rotation += 5;
  99.          chopper.jet._rotation -= 5;
  100.       }
  101.    }
  102.    else
  103.    {
  104.       if(chopper._rotation > 0)
  105.       {
  106.          chopper._rotation -= 5;
  107.          chopper.jet._rotation += 5;
  108.       }
  109.       if(key.isdown(key.left))
  110.       {
  111.          chopper._xscale *= -1;
  112.          chopper._rotation *= -1;
  113.          direct *= -1;
  114.       }
  115.    }
  116.    offset = random(6);
  117.    bulletxmove = Math.cos(0.017453292519943295 * chopper._rotation) * (20 + offset) * direct;
  118.    bulletymove = Math.sin(0.017453292519943295 * chopper._rotation) * (20 + offset) * direct;
  119.    bulletxorg = Math.cos(0.017453292519943295 * (chopper._rotation - 90)) * 14;
  120.    bulletyorg = Math.sin(0.017453292519943295 * (chopper._rotation - 90)) * 14;
  121.    testx = _X + xmove;
  122.    testy = _Y + ymove;
  123.    if(testx > 300 and testx < _loc1_.stagew - 300)
  124.    {
  125.       if(direct > 0)
  126.       {
  127.          _loc1_.movevar = -3;
  128.       }
  129.       else
  130.       {
  131.          _loc1_.movevar = 3;
  132.       }
  133.    }
  134.    else
  135.    {
  136.       testx2 = _loc1_.scanner.targbox._x + xmove * 0.1;
  137.       if(testx2 > 450 and testx2 < 550)
  138.       {
  139.          xmove = 0;
  140.          _loc1_.movevar = 0;
  141.       }
  142.       else if(testx2 < 0 and testx2 > -100)
  143.       {
  144.          xmove = 0;
  145.          _loc1_.movevar = 0;
  146.       }
  147.       else
  148.       {
  149.          _loc1_.movevar = xmove * -1;
  150.          _loc1_.scanner.targbox._x = testx2;
  151.       }
  152.    }
  153.    if(testy > 24 and testy < _loc1_.stageh - 50)
  154.    {
  155.       _Y = testy;
  156.    }
  157.    if(butx eq "false")
  158.    {
  159.       if(Math.abs(xmove) > 1)
  160.       {
  161.          xmove *= 0.9;
  162.       }
  163.       else
  164.       {
  165.          xmove = 0;
  166.       }
  167.    }
  168.    if(buty eq "false")
  169.    {
  170.       if(Math.abs(ymove) > 1)
  171.       {
  172.          ymove *= 0.7;
  173.       }
  174.       else
  175.       {
  176.          ymove = 0;
  177.       }
  178.    }
  179. }
  180. move = 10;
  181. cnt = 0;
  182. flip = "false";
  183. blink = "false";
  184. _root.collide = "true";
  185. direct = 1;
  186. hits = 20;
  187. hitvar = 50 / hits;
  188. ymove = 0;
  189. xmove = 0;
  190. buty = "false";
  191. butx = "false";
  192. _root.arrows.gotoAndStop("blank");
  193.