home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Diversos / clowns.swf / scripts / DefineSprite_366 / frame_5 / DoAction.as
Encoding:
Text File  |  2006-06-13  |  5.5 KB  |  245 lines

  1. if(getTimer() - startTime > 1000)
  2. {
  3.    startTime += 1000;
  4.    _root.console.time--;
  5.    if(_root.console.time == 0)
  6.    {
  7.       gotoAndPlay(9);
  8.    }
  9. }
  10. if(Key.isDown(_global.opt.keyUp))
  11. {
  12.    i = 0;
  13.    while(i < 2)
  14.    {
  15.       clowns[i].plankX += 0.1 * clowns[i].mirrorX;
  16.       i++;
  17.    }
  18. }
  19. if(Key.isDown(_global.opt.keyDown))
  20. {
  21.    i = 0;
  22.    while(i < 2)
  23.    {
  24.       clowns[i].plankX -= 0.1 * clowns[i].mirrorX;
  25.       i++;
  26.    }
  27. }
  28. i = 0;
  29. while(i < 2)
  30. {
  31.    if(Math.abs(clowns[i].plankX < 0))
  32.    {
  33.       clowns[i].plankX = 0;
  34.    }
  35.    if(Math.abs(clowns[i].plankX > 1))
  36.    {
  37.       clowns[i].plankX = 1;
  38.    }
  39.    i++;
  40. }
  41. if(Key.isDown(_global.opt.keyRight))
  42. {
  43.    if(vx < 0)
  44.    {
  45.       vx = 0;
  46.    }
  47.    vx += ax;
  48.    if(vx > vxMax)
  49.    {
  50.       vx = vxMax;
  51.    }
  52. }
  53. if(Key.isDown(_global.opt.keyLeft))
  54. {
  55.    if(vx > 0)
  56.    {
  57.       vx = 0;
  58.    }
  59.    vx -= ax;
  60.    if(vx < -1 * vxMax)
  61.    {
  62.       vx = -1 * vxMax;
  63.    }
  64. }
  65. plankTargetX = mainSprite._x + vx;
  66. if(Math.abs(vx) > 0)
  67. {
  68.    mainSprite.cycle.monkey.play();
  69.    mainSprite.cycle.monkeyLeg.play();
  70.    mainSprite.cycle.play();
  71. }
  72. else
  73. {
  74.    mainSprite.cycle.monkey.stop();
  75.    mainSprite.cycle.monkeyLeg.stop();
  76.    mainSprite.cycle.stop();
  77. }
  78. vx = 0;
  79. if(plankTargetX > wallRight)
  80. {
  81.    plankTargetX = wallRight;
  82.    vx = 0;
  83. }
  84. if(plankTargetX < wallLeft)
  85. {
  86.    plankTargetX = wallLeft;
  87.    vx = 0;
  88. }
  89. mainSprite._x = plankTargetX;
  90. i = 0;
  91. while(i < 2)
  92. {
  93.    if(clowns[i].mode == MODE_FLYING)
  94.    {
  95.       clowns[i].vy += gravity;
  96.       clowns[i].targetX = clowns[i]._x + clowns[i].vx;
  97.       clowns[i].targetY = clowns[i]._y + clowns[i].vy;
  98.       clowns[i].plankX = calcPlankLandingX(i);
  99.       if(clowns[i].vy > 0 && clowns[i].targetY > wippeTop && calcOnPlankY(i) <= clowns[i].targetY)
  100.       {
  101.          if(clowns[i].plankX > 1 || clowns[i].plankX < 0)
  102.          {
  103.             if(clowns[i].targetY > axisY)
  104.             {
  105.                clowns[i]._y = wallBottom - 7;
  106.                clowns[i].mode = MODE_RETURNING;
  107.                tDamage = Math.abs(clowns[i].vy) * 0.07 - 0.5;
  108.                tDamage *= 1.3;
  109.                if(tDamage < 0)
  110.                {
  111.                   tDamage = 0;
  112.                }
  113.                damageHealth(clowns[i],tDamage);
  114.                clowns[i].vy = 0;
  115.                clowns[i].plankX = 0.7;
  116.             }
  117.          }
  118.          else
  119.          {
  120.             if(clowns[i].vy < 4)
  121.             {
  122.                clowns[i].vy = 4;
  123.             }
  124.             vr = clowns[i].vy * clowns[i].mirrorX;
  125.             clowns[i].mode = MODE_STANDING;
  126.             clowns[i].gotoAndStop("standing");
  127.             clowns[i].partner.gotoAndStop("prejump");
  128.          }
  129.       }
  130.       clowns[i].plankX = Math.abs(clowns[i].plankX);
  131.    }
  132.    if(clowns[i].mode == MODE_FLYING)
  133.    {
  134.       clowns[i]._x = clowns[i].targetX;
  135.       clowns[i]._y = clowns[i].targetY;
  136.    }
  137.    else if(clowns[i].mode == MODE_RETURNING && clowns[i].health > 0)
  138.    {
  139.       if(clowns[i]._x < -50)
  140.       {
  141.          clowns[i]._x = -50;
  142.       }
  143.       if(clowns[i]._x > 600)
  144.       {
  145.          clowns[i]._x = 600;
  146.       }
  147.       if(Math.abs(clowns[i]._x - calcOnPlankX(i)) > 4)
  148.       {
  149.          if(clowns[i]._x > calcOnPlankX(i))
  150.          {
  151.             clowns[i]._x -= 5;
  152.             clowns[i].gotoAndStop("walk_left");
  153.          }
  154.          else
  155.          {
  156.             clowns[i]._x += 5;
  157.             clowns[i].gotoAndStop("walk_right");
  158.          }
  159.       }
  160.       else
  161.       {
  162.          clowns[i].mode = MODE_FLYING;
  163.          clowns[i].gotoAndStop("jump_" + clowns[i].lookDir);
  164.          clowns[i].vx = 0;
  165.          clowns[i].vy = -5;
  166.       }
  167.    }
  168.    else if(clowns[i].mode == MODE_STANDING)
  169.    {
  170.       clowns[i]._x = calcOnPlankX(i);
  171.       clowns[i]._y = calcOnPlankY(i);
  172.    }
  173.    i++;
  174. }
  175. plankTargetR = mainSprite.plank._rotation + vr * 2;
  176. if(Math.abs(plankTargetR) > mainSprite.plank.maxRotation)
  177. {
  178.    if(plankTargetR > 0)
  179.    {
  180.       clownLeft.mode = MODE_FLYING;
  181.       clownLeft.gotoAndStop("fly_right");
  182.       clownLeft.vy = -0.9 * Math.abs(vr) * (Math.abs(clownRight.plankX) + 0.7);
  183.       clownLeft.vx = -1 * Math.abs(vr) * (Math.abs(clownLeft.plankX) - 0.7);
  184.       mainSprite.plank._rotation = mainSprite.plank.maxRotation;
  185.    }
  186.    else
  187.    {
  188.       clownRight.mode = MODE_FLYING;
  189.       clownRight.gotoAndStop("fly_left");
  190.       clownRight.vy = -0.9 * Math.abs(vr) * (Math.abs(clownLeft.plankX) + 0.7);
  191.       clownRight.vx = 1 * Math.abs(vr) * (Math.abs(clownRight.plankX) - 0.7);
  192.       mainSprite.plank._rotation = -1 * mainSprite.plank.maxRotation;
  193.    }
  194.    vr = 0;
  195. }
  196. else
  197. {
  198.    mainSprite.plank._rotation = plankTargetR;
  199. }
  200. if(clowns[0].mode == MODE_FLYING)
  201. {
  202.    flyingClown = clowns[0];
  203. }
  204. else
  205. {
  206.    flyingClown = clowns[1];
  207. }
  208. i = 0;
  209. while(i < sensorAmount)
  210. {
  211.    if(sensors[i].active)
  212.    {
  213.       if(matterHitTest(flyingClown._x,flyingClown._y,i))
  214.       {
  215.          if(sensors[i].dieAtDanger)
  216.          {
  217.             if(deadlyHitTest(flyingClown._x,flyingClown._y,i))
  218.             {
  219.                canMove = true;
  220.                gotoAndPlay(7);
  221.             }
  222.          }
  223.          if(sensors[i].hitObjects)
  224.          {
  225.             hits = objectsHitTest(flyingClown._x,flyingClown._y,i);
  226.             hitI = 0;
  227.             while(true)
  228.             {
  229.                if(!hits[hitI])
  230.                {
  231.                   break;
  232.                }
  233.                hits[hitI].touch();
  234.                hitI++;
  235.             }
  236.          }
  237.       }
  238.    }
  239.    i++;
  240. }
  241. if(needCollect <= 0)
  242. {
  243.    gotoAndPlay(11);
  244. }
  245.