private void UpdateMovement(InputState inputState) { if (mCurrentState == State.Ground || mCurrentState == State.Platform || mCurrentState == State.Portal) { if (Math.Abs(Velocity.X) <= STATIC_ACCEL_GND) { Acceleration.X = 0; Velocity.X = 0; } else Acceleration.X = mCurrentFriction * (-Math.Sign(Velocity.X)); if (inputState.IsMovingBackwards(null)) { Velocity.X = DEFAULT_SPEED * MOVE_LEFT * (mIsDucking ? .5f : 1); } else if (inputState.IsMovingForward(null)) { Velocity.X = DEFAULT_SPEED * MOVE_RIGHT * (mIsDucking ? .5f : 1); } } else if(mCurrentState == State.Air || mCurrentState == State.GravityPortal) { if (Math.Abs(Velocity.X) <= STATIC_ACCEL_AIR) { Acceleration.X = 0; Velocity.X = 0; } else { Acceleration.X = DYNAMIC_ACCEL_AIR * (Math.Abs(Velocity.X) <= STATIC_ACCEL_AIR ? 0 : 1) * (-Math.Sign(Velocity.X)); } if (inputState.IsMovingBackwards(null)) { //Acceleration.X += DYNAMIC_ACCEL_AIR * MOVE_LEFT / 4; Velocity.X = Math.Min(Velocity.X, DEFAULT_SPEED / 2f * MOVE_LEFT * (mIsDucking ? .5f : 1)); } else if (inputState.IsMovingForward(null)) { //Acceleration.X += DYNAMIC_ACCEL_AIR * MOVE_RIGHT / 4; Velocity.X = Math.Max(Velocity.X, DEFAULT_SPEED / 2f * MOVE_RIGHT * (mIsDucking ? .5f : 1)); } //if (mIsDucking) // Acceleration.X *= .75f; //} } }
//UNDER CONSTRUCTION private void UpdateMovement(InputState inputState) { bool invert = Math.Abs(Angle) > MathHelper.PiOver2; //Movement while on the ground is UNDER CONSTRUCTION (values are hardcoded) if (mCurrentState == State.Ground || mCurrentState == State.Platform || mCurrentState == State.Portal) { if (Math.Abs(Velocity.X) <= STATIC_ACCEL_GND) { Acceleration.X = 0; Velocity.X = 0; } else Acceleration.X = mCurrentFriction * (-Math.Sign(Velocity.X)); if ((inputState.IsMovingBackwards(null) && !invert) || (inputState.IsMovingForward(null) && invert)) { Velocity.X = DEFAULT_SPEED * MOVE_LEFT * (mIsDucking ? .5f : 1); if (mIsDucking) { } else { animator.PlayAnimation(runAnimation); } } else if ((inputState.IsMovingBackwards(null) && invert) || (inputState.IsMovingForward(null) && !invert)) { Velocity.X = DEFAULT_SPEED * MOVE_RIGHT * (mIsDucking ? .5f : 1); if (mIsDucking) { } else { animator.PlayAnimation(runAnimation); } } else { animator.PlayAnimation(idleAnimation); } } //Movement while in the AIR is UNDER CONSTRUCTION (values are hardcoded) else if (mCurrentState == State.Air || mCurrentState == State.GravityPortal) { if (Math.Abs(Velocity.X) <= STATIC_ACCEL_AIR) { Acceleration.X = 0; Velocity.X = 0; } else { Acceleration.X = DYNAMIC_ACCEL_AIR * (Math.Abs(Velocity.X) <= STATIC_ACCEL_AIR ? 0 : 1) * (-Math.Sign(Velocity.X)); } if ((inputState.IsMovingBackwards(null) && !invert) || (inputState.IsMovingForward(null) && invert)) { //Acceleration.X += DYNAMIC_ACCEL_AIR * MOVE_LEFT / 4; //Velocity.X = Math.Min(Velocity.X, DEFAULT_SPEED / 2f * MOVE_LEFT * (mIsDucking ? .5f : 1)); if (Velocity.X >= -DEFAULT_SPEED) { if (Velocity.X > 0) { Velocity.X -= 50; } else { Velocity.X -= 25; } } animator.PlayAnimation(jumpAnimation); } else if ((inputState.IsMovingBackwards(null) && invert) || (inputState.IsMovingForward(null) && !invert)) { //Acceleration.X += DYNAMIC_ACCEL_AIR * MOVE_RIGHT / 4; //Velocity.X = Math.Max(Velocity.X, DEFAULT_SPEED / 2f * MOVE_RIGHT * (mIsDucking ? .5f : 1)); if (Velocity.X <= DEFAULT_SPEED) { if (Velocity.X < 0) { Velocity.X += 50; } else { Velocity.X += 25; } } animator.PlayAnimation(jumpAnimation); } //if (mIsDucking) // Acceleration.X *= .75f; //} } }