/// <summary> /// Checks the currently pressed keys and changes the acceleration vector accordingly /// </summary> private void ApplyAcceleration() { var shape = Shape.AsDynamicShape(); if (mA[0] == 1 && mA[1] == 0 && mA[2] == 0) { Force.ApplyForce(new Vec2F(-Constants.TAXI_ACCEL_X, 0f), shape); taxiDirection = TaxiDirection.Left; } else if (mA[0] == 1 && mA[1] == 1 && mA[2] == 0) { Force.ApplyForce(new Vec2F(-Constants.TAXI_ACCEL_X, Constants.TAXI_ACCEL_Y), shape); taxiDirection = TaxiDirection.LeftAndUp; } else if (mA[0] == 0 && mA[1] == 1 && mA[2] == 0) { Force.ApplyForce(new Vec2F(0f, Constants.TAXI_ACCEL_Y), shape); taxiDirection = TaxiDirection.Up; } else if (mA[0] == 0 && mA[1] == 1 && mA[2] == 1) { Force.ApplyForce(new Vec2F(Constants.TAXI_ACCEL_X, Constants.TAXI_ACCEL_Y), shape); taxiDirection = TaxiDirection.RightAndUp; } else if (mA[0] == 0 && mA[1] == 0 && mA[2] == 1) { Force.ApplyForce(new Vec2F(Constants.TAXI_ACCEL_X, 0f), shape); taxiDirection = TaxiDirection.Right; } else if (mA[0] == 0 && mA[1] == 0 && mA[2] == 0) { taxiDirection = TaxiDirection.None; } Force.ApplyGravity(shape.AsDynamicShape()); }
public void ApplyGravityAppliesCorrectAcceleration() { Force.ApplyGravity(testShape); testShape.Move(); //measure movement caused by ApplyGravity var dX = Math.Abs(testShape.Position.X) - Math.Abs(Constants.GRAVITY_X); var dY = Math.Abs(testShape.Position.Y) - Math.Abs(Constants.GRAVITY_Y); Assert.IsTrue(((dX < AcceptableDeviance) && (dY < AcceptableDeviance))); }