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

  1. temp = random(2);
  2. if(temp == 0)
  3. {
  4.    player._y = 25;
  5. }
  6. else
  7. {
  8.    player._y = 575;
  9. }
  10. player._x = 25 + random(650);
  11. driftSpeed = 0.01;
  12. circx = player._x;
  13. circy = player._y;
  14. prevx = _root.base._x;
  15. prevy = _root.base._y;
  16. angle = 0;
  17. degrees = 0;
  18. onEnterFrame = function()
  19. {
  20.    if(circx < prevx && circy < prevy)
  21.    {
  22.       angle = Math.atan(Math.abs(circy - prevy) / Math.abs(circx - prevx));
  23.       degrees = angle * 180 / 3.141592653589793;
  24.       player._rotation = degrees + 90;
  25.    }
  26.    else if(circx < prevx && circy > prevy)
  27.    {
  28.       angle = Math.atan(Math.abs(circy - prevy) / Math.abs(circx - prevx));
  29.       degrees = angle * 180 / 3.141592653589793;
  30.       player._rotation = 90 - degrees;
  31.    }
  32.    else if(circx > prevx && circy < prevy)
  33.    {
  34.       angle = Math.atan(Math.abs(circx - prevx) / Math.abs(circy - prevy));
  35.       degrees = angle * 180 / 3.141592653589793;
  36.       player._rotation = - (180 - degrees);
  37.    }
  38.    else if(circx > prevx && circy > prevy)
  39.    {
  40.       angle = Math.atan(Math.abs(circy - prevy) / Math.abs(circx - prevx));
  41.       degrees = angle * 180 / 3.141592653589793;
  42.       player._rotation = - (90 - degrees);
  43.    }
  44.    circx = player._x;
  45.    circy = player._y;
  46.    prevx = _root._xmouse;
  47.    prevy = _root._ymouse;
  48.    player._x -= driftSpeed * ((player._x - _root.base._x) / 2);
  49.    player._y -= driftSpeed * ((player._y - _root.base._y) / 2);
  50.    if(Math.sqrt(Math.pow(circx - prevx,2) + Math.pow(circy - prevy,2)) >= 100)
  51.    {
  52.       player._x -= driftSpeed * 4 * ((player._x - _root.base._x) / 2);
  53.       player._y -= driftSpeed * 4 * ((player._y - _root.base._y) / 2);
  54.    }
  55.    if(player.hitTest(_root.base))
  56.    {
  57.       _root.base.play();
  58.       _root.life = _root.life - 1;
  59.    }
  60.    if(_root.life <= 0)
  61.    {
  62.       i = 0;
  63.       while(i < 4)
  64.       {
  65.          e = _root.attachMovie("lineline11","l" + _root.k,_root.k++);
  66.          e._x = player._x;
  67.          e._y = player._y;
  68.          i++;
  69.       }
  70.       this.removeMovieClip();
  71.    }
  72. };
  73. onMouseDown = function()
  74. {
  75.    if(player.hitTest(_root._xmouse,_root._ymouse))
  76.    {
  77.       _root.score += 650;
  78.       _root.hitted.start();
  79.       _root.kill = _root.kill + 1;
  80.       i = 0;
  81.       while(i < 10)
  82.       {
  83.          _root.attachMovie("lineline11","l" + _root.k,_root.k++);
  84.          i++;
  85.       }
  86.       this.removeMovieClip();
  87.    }
  88. };
  89.