home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / ellipsis.swf / scripts / DefineSprite_47_enemy3 / frame_1 / DoAction.as
Encoding:
Text File  |  2007-02-20  |  2.0 KB  |  80 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.03;
  12. angle = 0;
  13. degrees = 0;
  14. onEnterFrame = function()
  15. {
  16.    circx = player._x;
  17.    circy = player._y;
  18.    prevx = _root._xmouse;
  19.    prevy = _root._ymouse;
  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.    player._x -= driftSpeed * ((player._x - _root._xmouse) / 2);
  45.    player._y -= driftSpeed * ((player._y - _root._ymouse) / 2);
  46.    if(player.hitTest(_root.base))
  47.    {
  48.       _root.base.play();
  49.       _root.life = _root.life - 1;
  50.    }
  51.    if(_root.life <= 0)
  52.    {
  53.       i = 0;
  54.       while(i < 4)
  55.       {
  56.          e = _root.attachMovie("lineline6","l" + _root.k,_root.k++);
  57.          e._x = player._x;
  58.          e._y = player._y;
  59.          i++;
  60.       }
  61.       this.removeMovieClip();
  62.    }
  63. };
  64. onMouseDown = function()
  65. {
  66.    if(player.hitTest(_root._xmouse,_root._ymouse))
  67.    {
  68.       _root.score += 500;
  69.       _root.hitted.start();
  70.       _root.kill = _root.kill + 1;
  71.       i = 0;
  72.       while(i < 10)
  73.       {
  74.          _root.attachMovie("lineline6","l" + _root.k,_root.k++);
  75.          i++;
  76.       }
  77.       this.removeMovieClip();
  78.    }
  79. };
  80.