home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / games / jump_gam.swf / scripts / frame_172 / DoAction_2.as < prev    next >
Encoding:
Text File  |  2010-04-12  |  3.2 KB  |  126 lines

  1. function KeyTrackerManager(baseLineBonus, baseLineSubtract, baseLineSubtractLimit, timeCycle, decayFactor)
  2. {
  3.    var _loc1_ = this;
  4.    _loc1_.decayFactor = decayFactor;
  5.    _loc1_.baseLineBonus = baseLineBonus;
  6.    _loc1_.baseLineSubtract = baseLineSubtract;
  7.    _loc1_.baseLineSubtractLimit = baseLineSubtractLimit;
  8.    _loc1_.timeCycle = timeCycle;
  9. }
  10. function KeyTracker(keyA, keyB, parent)
  11. {
  12.    var _loc1_ = this;
  13.    _parent = parent;
  14.    _loc1_.keyA = keyA;
  15.    _loc1_.keyB = keyB;
  16.    Key.addListener(_loc1_);
  17. }
  18. function JumpTracker(keyA, keyB, keyC, keyD, keyE, keyF)
  19. {
  20.    var _loc1_ = this;
  21.    _loc1_.keyA = keyA;
  22.    _loc1_.trick1 = keyB;
  23.    _loc1_.trick2 = keyC;
  24.    _loc1_.trick3 = keyD;
  25.    _loc1_.trick4 = keyE;
  26.    _loc1_.trick5 = keyF;
  27.    Key.addListener(_loc1_);
  28. }
  29. KeyTrackerManager.prototype.onMyKeyPress = function(whichKey)
  30. {
  31.    var _loc1_ = this;
  32.    if(_loc1_.currentKey != whichKey && cameraDummy.stoppedRunning)
  33.    {
  34.       _loc1_.myTotalMomentum += _loc1_.baseLineBonus;
  35.       if(_loc1_.myTotalMomentum > 100)
  36.       {
  37.          _loc1_.myTotalMomentum = 100;
  38.       }
  39.       _loc1_.currentKey = whichKey;
  40.    }
  41. };
  42. KeyTrackerManager.prototype.getMomentum = function()
  43. {
  44.    return this.myTotalMomentum;
  45. };
  46. KeyTrackerManager.prototype.init = function()
  47. {
  48.    var _loc1_ = this;
  49.    _loc1_.currentTime = "";
  50.    _loc1_.storedTime = 0;
  51.    _loc1_.myTotalMomentum = 0;
  52.    _loc1_.currentKey = 0;
  53.    _loc1_.removeIntervals();
  54.    _loc1_.momentumBuffer = setInterval(_loc1_,"reduceMomentum",_loc1_.timeCycle);
  55. };
  56. KeyTrackerManager.prototype.reduceMomentum = function()
  57. {
  58.    var _loc1_ = this;
  59.    var _loc2_ = _loc1_.myTotalMomentum - _loc1_.baseLineSubtractLimit;
  60.    if(_loc2_ < 0)
  61.    {
  62.       _loc2_ = 0;
  63.    }
  64.    _loc2_ *= _loc1_.decayFactor;
  65.    var _loc3_ = _loc1_.baseLineSubtract + _loc2_;
  66.    if(_loc1_.myTotalMomentum - _loc3_ > 0)
  67.    {
  68.       _loc1_.myTotalMomentum -= _loc3_;
  69.    }
  70.    else
  71.    {
  72.       _loc1_.myTotalMomentum = 0;
  73.    }
  74. };
  75. KeyTrackerManager.prototype.removeIntervals = function()
  76. {
  77.    clearInterval(this.momentumBuffer);
  78. };
  79. KeyTracker.prototype.onKeyDown = function()
  80. {
  81.    var _loc1_ = this;
  82.    _loc1_.thisKey = Key.getCode();
  83.    if(_loc1_.thisKey == _loc1_.keyA || _loc1_.thisKey == _loc1_.keyB)
  84.    {
  85.       _parent.onMyKeyPress(_loc1_.thisKey);
  86.    }
  87. };
  88. JumpTracker.prototype.onKeyDown = function()
  89. {
  90.    var _loc1_ = this;
  91.    currentKey = Key.getCode();
  92.    switch(currentKey)
  93.    {
  94.       case _loc1_.keyA:
  95.          jumper.getJumpThrow();
  96.          break;
  97.       case _loc1_.trick1:
  98.          jumper.setTrick(0);
  99.          break;
  100.       case _loc1_.trick2:
  101.          jumper.setTrick(1);
  102.          break;
  103.       case _loc1_.trick3:
  104.          jumper.setTrick(2);
  105.          break;
  106.       case _loc1_.trick4:
  107.          jumper.setTrick(3);
  108.          break;
  109.       case _loc1_.trick5:
  110.          jumper.setTrick(4);
  111.    }
  112. };
  113. JumpTracker.prototype.onKeyUp = function()
  114. {
  115.    if(Key.getCode() == this.keyA)
  116.    {
  117.       jumper.setJumpStatus(0);
  118.       angleTracker.getAngle();
  119.       angleTracker.stopTracking();
  120.    }
  121. };
  122. myManager = new KeyTrackerManager(6,1,60,myFrameInterval,0.075);
  123. myManager.myKeyTracker = new KeyTracker(72,74,myManager);
  124. myManager.init();
  125. myJumpTracker = new JumpTracker(32,53,54,55,56,57);
  126.