/// <summary> /// Gets the horizontal displacement of the user, in the x or z directoin /// </summary> /// <param name="fwdAccel">determines if the player is acceleratig fwds</param> /// <param name="backAccel">determines if the player is accelerating backwards</param> /// <param name="displacementCalculator">which displacement calculator is being used</param> private void HorizontalDisplacement(bool fwdAccel, bool backAccel, CalculateDisplacement displacementCalculator) { //if the player is accelerating fwds and hasnt reached a max velocity of 2 if (fwdAccel && displacementCalculator.ReturnVelocity() < MAX_SPEED) { //updating the displace emnt of the user displacementCalculator.Update(SIDE_WAYS_ACCELERATION); } else if (!fwdAccel && displacementCalculator.ReturnVelocity() > NO_VALUE && !IsJumping) { //updating the displace emnt of the user displacementCalculator.Update(-SIDE_WAYS_DECCELERATION); } //if the player is acceleratting backwards and they are moving less than the max speed if (backAccel && displacementCalculator.ReturnVelocity() > -MAX_SPEED) { //updating the displace emnt of the user displacementCalculator.Update(-SIDE_WAYS_ACCELERATION); } //if the player is not accelerating backwards anfd they are still moving, they are deccelrating else if (!backAccel && displacementCalculator.ReturnVelocity() < NO_VALUE && !IsJumping) { //updating the displace emnt of the user displacementCalculator.Update(SIDE_WAYS_DECCELERATION); } }