home *** CD-ROM | disk | FTP | other *** search
- function KeyTrackerManager(baseLineBonus, baseLineSubtract, baseLineSubtractLimit, timeCycle, decayFactor)
- {
- var _loc1_ = this;
- _loc1_.decayFactor = decayFactor;
- _loc1_.baseLineBonus = baseLineBonus;
- _loc1_.baseLineSubtract = baseLineSubtract;
- _loc1_.baseLineSubtractLimit = baseLineSubtractLimit;
- _loc1_.timeCycle = timeCycle;
- }
- function KeyTracker(keyA, keyB, parent)
- {
- var _loc1_ = this;
- _parent = parent;
- _loc1_.keyA = keyA;
- _loc1_.keyB = keyB;
- Key.addListener(_loc1_);
- }
- function JumpTracker(keyA, keyB, keyC, keyD, keyE, keyF)
- {
- var _loc1_ = this;
- _loc1_.keyA = keyA;
- _loc1_.trick1 = keyB;
- _loc1_.trick2 = keyC;
- _loc1_.trick3 = keyD;
- _loc1_.trick4 = keyE;
- _loc1_.trick5 = keyF;
- Key.addListener(_loc1_);
- }
- KeyTrackerManager.prototype.onMyKeyPress = function(whichKey)
- {
- var _loc1_ = this;
- if(_loc1_.currentKey != whichKey && cameraDummy.stoppedRunning)
- {
- _loc1_.myTotalMomentum += _loc1_.baseLineBonus;
- if(_loc1_.myTotalMomentum > 100)
- {
- _loc1_.myTotalMomentum = 100;
- }
- _loc1_.currentKey = whichKey;
- }
- };
- KeyTrackerManager.prototype.getMomentum = function()
- {
- return this.myTotalMomentum;
- };
- KeyTrackerManager.prototype.init = function()
- {
- var _loc1_ = this;
- _loc1_.currentTime = "";
- _loc1_.storedTime = 0;
- _loc1_.myTotalMomentum = 0;
- _loc1_.currentKey = 0;
- _loc1_.removeIntervals();
- _loc1_.momentumBuffer = setInterval(_loc1_,"reduceMomentum",_loc1_.timeCycle);
- };
- KeyTrackerManager.prototype.reduceMomentum = function()
- {
- var _loc1_ = this;
- var _loc2_ = _loc1_.myTotalMomentum - _loc1_.baseLineSubtractLimit;
- if(_loc2_ < 0)
- {
- _loc2_ = 0;
- }
- _loc2_ *= _loc1_.decayFactor;
- var _loc3_ = _loc1_.baseLineSubtract + _loc2_;
- if(_loc1_.myTotalMomentum - _loc3_ > 0)
- {
- _loc1_.myTotalMomentum -= _loc3_;
- }
- else
- {
- _loc1_.myTotalMomentum = 0;
- }
- };
- KeyTrackerManager.prototype.removeIntervals = function()
- {
- clearInterval(this.momentumBuffer);
- };
- KeyTracker.prototype.onKeyDown = function()
- {
- var _loc1_ = this;
- _loc1_.thisKey = Key.getCode();
- if(_loc1_.thisKey == _loc1_.keyA || _loc1_.thisKey == _loc1_.keyB)
- {
- _parent.onMyKeyPress(_loc1_.thisKey);
- }
- };
- JumpTracker.prototype.onKeyDown = function()
- {
- var _loc1_ = this;
- currentKey = Key.getCode();
- switch(currentKey)
- {
- case _loc1_.keyA:
- jumper.getJumpThrow();
- break;
- case _loc1_.trick1:
- jumper.setTrick(0);
- break;
- case _loc1_.trick2:
- jumper.setTrick(1);
- break;
- case _loc1_.trick3:
- jumper.setTrick(2);
- break;
- case _loc1_.trick4:
- jumper.setTrick(3);
- break;
- case _loc1_.trick5:
- jumper.setTrick(4);
- }
- };
- JumpTracker.prototype.onKeyUp = function()
- {
- if(Key.getCode() == this.keyA)
- {
- jumper.setJumpStatus(0);
- angleTracker.getAngle();
- angleTracker.stopTracking();
- }
- };
- myManager = new KeyTrackerManager(6,1,60,myFrameInterval,0.075);
- myManager.myKeyTracker = new KeyTracker(72,74,myManager);
- myManager.init();
- myJumpTracker = new JumpTracker(32,53,54,55,56,57);
-