Momentum gain

Version:

3.0

Added on:

25 Feb 2014 14:38

Tags:

Description:
This simple script changes the running mechanics. Instead of simply holding a button in order to achieve greater movement velocity, you now have to build up enough momentum in order to be able to run. This can be accomplished in two ways - either by holding a movement key for a long enough duration (two seconds to be exact), or by gaining speed via some kind of enabling feature, for example a horizontal spring or pole. You lose your momentum if you release the movement key, change direction or bump into something.

EDIT: Minor improvement.
uint warmupTime = 0;

void onPlayerInput(jjPLAYER@ play) {
  if ((play.keyLeft == true || play.keyRight == true) && play.xSpeed != 0) {
    warmupTime++;
  }
  else {
    warmupTime = 0;
  }

  if (play.keyLeft == true && play.direction == 1) {
    warmupTime = 0;
  }

  if (play.keyRight == true && play.direction == -1) {
    warmupTime = 0;
  }

  if (warmupTime >= 105 || play.xSpeed > 8 || play.xSpeed < -8) {
    play.keyRun = true;
  }
  else {
    play.keyRun = false;
  }
}