home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / ellipsis.swf / scripts / DefineSprite_41_enemy5 / frame_1 / DoAction.as
Encoding:
Text File  |  2007-02-20  |  4.1 KB  |  167 lines

  1. function moveMe()
  2. {
  3.    youSpeed = Math.min(youMaxSpeed,youSpeed + youAcc);
  4.    player._rotation += (Key.isDown(39) - Key.isDown(37)) * 7;
  5.    xC = Math.cos(player._rotation * 3.141592653589793 / 180) * youSpeed;
  6.    yC = Math.sin(player._rotation * 3.141592653589793 / 180) * youSpeed;
  7.    player._x += xC;
  8.    player._y += yC;
  9.    oldX = player._x;
  10.    oldY = player._y;
  11. }
  12. youAcc = 0.2;
  13. youDec = 0.2;
  14. youSpeed = 0;
  15. youMaxSpeed = 2;
  16. temp = random(2);
  17. if(temp == 0)
  18. {
  19.    player._x = 25;
  20. }
  21. else
  22. {
  23.    player._x = 575;
  24. }
  25. player._y = 25 + random(650);
  26. player._rotation = random(360);
  27. var sent = random(6) - 3;
  28. var sentD = "up";
  29. var sInc = 0.5;
  30. life *= 50;
  31. driftSpeed = 0.09;
  32. angle = 0;
  33. degrees = 0;
  34. onEnterFrame = function()
  35. {
  36.    moveMe();
  37.    circx = player._x;
  38.    circy = player._y;
  39.    prevx = _root._xmouse;
  40.    prevy = _root._ymouse;
  41.    if(circx < prevx && circy < prevy)
  42.    {
  43.       angle = Math.atan(Math.abs(circy - prevy) / Math.abs(circx - prevx));
  44.       degrees = angle * 180 / 3.141592653589793;
  45.       player._rotation = degrees + 90;
  46.    }
  47.    else if(circx < prevx && circy > prevy)
  48.    {
  49.       angle = Math.atan(Math.abs(circy - prevy) / Math.abs(circx - prevx));
  50.       degrees = angle * 180 / 3.141592653589793;
  51.       player._rotation = 90 - degrees;
  52.    }
  53.    else if(circx > prevx && circy < prevy)
  54.    {
  55.       angle = Math.atan(Math.abs(circx - prevx) / Math.abs(circy - prevy));
  56.       degrees = angle * 180 / 3.141592653589793;
  57.       player._rotation = - (180 - degrees);
  58.    }
  59.    else if(circx > prevx && circy > prevy)
  60.    {
  61.       angle = Math.atan(Math.abs(circy - prevy) / Math.abs(circx - prevx));
  62.       degrees = angle * 180 / 3.141592653589793;
  63.       player._rotation = - (90 - degrees);
  64.    }
  65.    if(Math.sqrt(Math.pow(circx - prevx,2) + Math.pow(circy - prevy,2)) <= 200)
  66.    {
  67.       player._rotation += 90;
  68.    }
  69.    else
  70.    {
  71.       player._rotation -= 90;
  72.    }
  73.    if(player._rotation >= 360)
  74.    {
  75.       player._rotation -= 360;
  76.    }
  77.    if(player._rotation < 0)
  78.    {
  79.       player._rotation += 360;
  80.    }
  81.    if(player._x >= 575)
  82.    {
  83.       if(player._rotation >= 0 && player._rotation < 90)
  84.       {
  85.          player._rotation = 180 - player._rotation;
  86.          moveMe();
  87.       }
  88.       if(player._rotation < 0 && player._rotation > -90)
  89.       {
  90.          player._rotation = 180 - player._rotation;
  91.          moveMe();
  92.       }
  93.    }
  94.    if(player._x <= 25)
  95.    {
  96.       if(player._rotation <= 180 && player._rotation > 90)
  97.       {
  98.          player._rotation = 180 - player._rotation;
  99.          moveMe();
  100.       }
  101.       if(player._rotation > -180 && player._rotation < -90)
  102.       {
  103.          player._rotation = 180 - player._rotation;
  104.          moveMe();
  105.       }
  106.    }
  107.    if(player._y <= 25)
  108.    {
  109.       if(player._rotation >= -180 && player._rotation <= -90)
  110.       {
  111.          player._rotation = - player._rotation;
  112.          moveMe();
  113.       }
  114.       if(player._rotation >= -90 && player._rotation <= 0)
  115.       {
  116.          player._rotation = - player._rotation;
  117.          moveMe();
  118.       }
  119.    }
  120.    if(player._y >= 575)
  121.    {
  122.       if(player._rotation >= 90 && player._rotation <= 180)
  123.       {
  124.          player._rotation = - player._rotation;
  125.          moveMe();
  126.       }
  127.       if(player._rotation <= 90 && player._rotation >= 0)
  128.       {
  129.          player._rotation = - player._rotation;
  130.          moveMe();
  131.       }
  132.    }
  133.    if(player.hitTest(_root.base))
  134.    {
  135.       _root.base.play();
  136.       _root.life = _root.life - 1;
  137.    }
  138.    if(_root.life <= 0)
  139.    {
  140.       i = 0;
  141.       while(i < 4)
  142.       {
  143.          e = _root.attachMovie("lineline8","l" + _root.k,_root.k++);
  144.          e._x = player._x;
  145.          e._y = player._y;
  146.          i++;
  147.       }
  148.       this.removeMovieClip();
  149.    }
  150. };
  151. onMouseDown = function()
  152. {
  153.    if(player.hitTest(_root._xmouse,_root._ymouse))
  154.    {
  155.       _root.score += 450;
  156.       _root.hitted.start();
  157.       _root.kill = _root.kill + 1;
  158.       i = 0;
  159.       while(i < 10)
  160.       {
  161.          _root.attachMovie("lineline8","l" + _root.k,_root.k++);
  162.          i++;
  163.       }
  164.       this.removeMovieClip();
  165.    }
  166. };
  167.