home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / ellipsis.swf / scripts / DefineSprite_38_enemy2 / frame_1 / DoAction.as
Encoding:
Text File  |  2007-02-20  |  3.1 KB  |  137 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. player._x = _root._xmouse;
  17. player._y = _root._ymouse;
  18. player._rotation = random(360);
  19. var sent = random(6) - 3;
  20. var sentD = "up";
  21. var sInc = 0.5;
  22. life *= 50;
  23. onEnterFrame = function()
  24. {
  25.    if(sentD == "down")
  26.    {
  27.       sent -= sInc;
  28.       if(sent <= -5)
  29.       {
  30.          sentD = "up";
  31.       }
  32.    }
  33.    else if(sentD == "up")
  34.    {
  35.       sent += sInc;
  36.       if(sent >= 5)
  37.       {
  38.          sentD = "down";
  39.       }
  40.    }
  41.    moveMe();
  42.    player._rotation += sent;
  43.    if(player._rotation >= 360)
  44.    {
  45.       player._rotation -= 360;
  46.    }
  47.    if(player._rotation < 0)
  48.    {
  49.       player._rotation += 360;
  50.    }
  51.    if(player._x >= 575)
  52.    {
  53.       if(player._rotation >= 0 && player._rotation < 90)
  54.       {
  55.          player._rotation = 180 - player._rotation;
  56.          moveMe();
  57.       }
  58.       if(player._rotation < 0 && player._rotation > -90)
  59.       {
  60.          player._rotation = 180 - player._rotation;
  61.          moveMe();
  62.       }
  63.    }
  64.    if(player._x <= 25)
  65.    {
  66.       if(player._rotation <= 180 && player._rotation > 90)
  67.       {
  68.          player._rotation = 180 - player._rotation;
  69.          moveMe();
  70.       }
  71.       if(player._rotation > -180 && player._rotation < -90)
  72.       {
  73.          player._rotation = 180 - player._rotation;
  74.          moveMe();
  75.       }
  76.    }
  77.    if(player._y <= 25)
  78.    {
  79.       if(player._rotation >= -180 && player._rotation <= -90)
  80.       {
  81.          player._rotation = - player._rotation;
  82.          moveMe();
  83.       }
  84.       if(player._rotation >= -90 && player._rotation <= 0)
  85.       {
  86.          player._rotation = - player._rotation;
  87.          moveMe();
  88.       }
  89.    }
  90.    if(player._y >= 575)
  91.    {
  92.       if(player._rotation >= 90 && player._rotation <= 180)
  93.       {
  94.          player._rotation = - player._rotation;
  95.          moveMe();
  96.       }
  97.       if(player._rotation <= 90 && player._rotation >= 0)
  98.       {
  99.          player._rotation = - player._rotation;
  100.          moveMe();
  101.       }
  102.    }
  103.    if(player.hitTest(_root.base))
  104.    {
  105.       _root.base.play();
  106.       _root.life = _root.life - 1;
  107.    }
  108.    if(_root.life <= 0)
  109.    {
  110.       i = 0;
  111.       while(i < 4)
  112.       {
  113.          e = _root.attachMovie("lineline5","l" + _root.k,_root.k++);
  114.          e._x = player._x;
  115.          e._y = player._y;
  116.          i++;
  117.       }
  118.       this.removeMovieClip();
  119.    }
  120. };
  121. onMouseDown = function()
  122. {
  123.    if(player.hitTest(_root._xmouse,_root._ymouse))
  124.    {
  125.       _root.score += 400;
  126.       _root.hitted.start();
  127.       _root.kill = _root.kill + 1;
  128.       i = 0;
  129.       while(i < 10)
  130.       {
  131.          _root.attachMovie("lineline5","l" + _root.k,_root.k++);
  132.          i++;
  133.       }
  134.       this.removeMovieClip();
  135.    }
  136. };
  137.