home *** CD-ROM | disk | FTP | other *** search
/ One Click 21 (Special) / OC021.iso / Juegos / 04-10-20-2.swf / scripts / DefineSprite_599 / frame_1 / DoAction.as
Encoding:
Text File  |  2005-11-18  |  3.1 KB  |  139 lines

  1. function moveRight()
  2. {
  3.    if(boy._x + width < rBounds - 5 && !animActive)
  4.    {
  5.       boy._x += xspeed;
  6.       boy.stand.gotoAndStop(2);
  7.    }
  8. }
  9. function moveLeft()
  10. {
  11.    if(lBounds + 5 < boy._x - width && !animActive)
  12.    {
  13.       boy._x -= xspeed;
  14.       boy.stand.gotoAndStop(2);
  15.    }
  16. }
  17. function lateralFall()
  18. {
  19.    if(boy._x - width < lLedge || rLedge < boy._x + width)
  20.    {
  21.       findGlobal(bBottom._y);
  22.       boy._y = Math.round(bBottom._y);
  23.       bottom = Math.round(bBottom._y);
  24.       lLedge = Math.round(bBottom._x);
  25.       rLedge = Math.round(bBottom._x + bBottom._width);
  26.       boy.gotoAndPlay("falling");
  27.       ySpeed = 0;
  28.       jumping = 0;
  29.    }
  30. }
  31. function jumpCommand()
  32. {
  33.    if(jumping == 0 && !animActive)
  34.    {
  35.       ySpeed -= jumpPower;
  36.       jumping = 1;
  37.       boy.gotoAndPlay("jump");
  38.    }
  39. }
  40. function jumpMovement()
  41. {
  42.    hitLedgeTest();
  43.    if(bottom < y && jumping == 1)
  44.    {
  45.       if(boy._x - width < lLedge || rLedge < boy._x + width)
  46.       {
  47.          findGlobal(bBottom._y);
  48.          boy._y = Math.round(bBottom._y);
  49.          bottom = Math.round(bBottom._y);
  50.          lLedge = Math.round(bBottom._x);
  51.          rLedge = Math.round(bBottom._x + bBottom._width);
  52.          boy.gotoAndPlay("falling");
  53.          ySpeed = 0;
  54.          jumping = 0;
  55.       }
  56.       else
  57.       {
  58.          ySpeed = 0;
  59.          y = bottom;
  60.          boy.gotoAndStop("standing");
  61.          jumping = 0;
  62.       }
  63.    }
  64.    else
  65.    {
  66.       y = boy._y;
  67.       ySpeed += gam2Yinc;
  68.       y += ySpeed / 8;
  69.       boy._y = y;
  70.    }
  71. }
  72. function hitLedgeTest()
  73. {
  74.    var tempBottom;
  75.    i = 1;
  76.    while(ledgeNum >= i)
  77.    {
  78.       if(boy.grabArea.hitTest(this["l" + i].ledge))
  79.       {
  80.          if(this["l" + i] == this["l" + ledgeNum])
  81.          {
  82.             boyHitTop = true;
  83.          }
  84.          bottom = this["l" + i]._y;
  85.          lLedge = Math.round(this["l" + i]._x);
  86.          rLedge = Math.round(this["l" + i]._x + this["l" + i]._width);
  87.          ySpeed = 0;
  88.          boy._y = bottom;
  89.          boy.gotoAndStop("climbing");
  90.          jumping = 0;
  91.          tempBottom = bottom;
  92.          findGlobal(tempBottom);
  93.       }
  94.       i++;
  95.    }
  96. }
  97. function findGlobal(tempBottom)
  98. {
  99.    var tempBottom;
  100.    var point = new Object();
  101.    point.x = tempBottom;
  102.    point.y = tempBottom;
  103.    this.localToGlobal(point);
  104.    yDist = viewPosition - point.y;
  105.    needNewView = true;
  106. }
  107. function adjustView()
  108. {
  109.    yDist -= scrollSpeed;
  110.    scrollSpeed = yDist * deAccel;
  111.    this._y += scrollSpeed;
  112.    if(Math.abs(yDist) < 1)
  113.    {
  114.       needNewView = false;
  115.    }
  116. }
  117. var ledgeNum = 21;
  118. var bottom = Math.round(bBottom._y);
  119. var lLedge = Math.round(bBottom._x);
  120. var rLedge = Math.round(bBottom._x + bBottom._width);
  121. var rBounds = Math.round(bBottom._x + bBottom._width);
  122. var lBounds = Math.round(bBottom._x);
  123. var width = 10;
  124. var height = 42;
  125. var jumpPower = 90;
  126. var game2time;
  127. var animActive = false;
  128. var needNewView = false;
  129. var boyHitTop = false;
  130. var jumping = 0;
  131. var boundsTop = Math.round(_root.btop._y);
  132. var deAccel = 0.25;
  133. var scrollSpeed = 0;
  134. var viewPosition = _root.viewPoint._y;
  135. var ySpeed;
  136. var xSpeed = 4;
  137. var gam2Yinc = 4;
  138. var gam2Xinc = 3;
  139.