Exemplo n.º 1
0
        public void Tick7Left2Right()
        {
            PlayerPhysics playerPhysics = new PlayerPhysics();
            var           acceleration  = playerPhysics.GetAcceleration();
            var           resistance    = playerPhysics.GetResistance();
            double        expectedVelocity;

            playerPhysics.AccelerateLeft();
            playerPhysics.CalculateVelocityThisTick();
            expectedVelocity = acceleration - resistance;
            playerPhysics.CalculateVelocityThisTick();
            expectedVelocity += acceleration - resistance;
            playerPhysics.CalculateVelocityThisTick();
            expectedVelocity += acceleration - resistance;
            playerPhysics.CalculateVelocityThisTick();
            expectedVelocity += acceleration - resistance;
            playerPhysics.CalculateVelocityThisTick();
            expectedVelocity += acceleration - resistance;
            playerPhysics.CalculateVelocityThisTick();
            expectedVelocity += acceleration - resistance;
            playerPhysics.CalculateVelocityThisTick();
            expectedVelocity += acceleration - resistance;
            playerPhysics.StopAccelerateLeft();

            playerPhysics.AccelerateRight();
            playerPhysics.CalculateVelocityThisTick();
            expectedVelocity += -acceleration - resistance;
            playerPhysics.CalculateVelocityThisTick();
            expectedVelocity += -acceleration - resistance;

            Assert.AreEqual(expectedVelocity, playerPhysics.GetVelocity());
        }