예제 #1
0
        public void TestShipVelocityWith100FramesOfThrust()
        {
            World testWorld = new World();

            testWorld.ShipAccel = 0.08;
            testWorld.SpawnShip(1, "testname");
            Ship testShip = (Ship)testWorld.getPlayers()[1];

            double xShipStart = testShip.GetLocation().GetX();
            double yShipStart = testShip.GetLocation().GetY();

            double xShipVel = testShip.GetVelocity().GetX();
            double yShipVel = testShip.GetVelocity().GetY();

            double xShip = testShip.GetLocation().GetX();
            double yShip = testShip.GetLocation().GetY();


            Assert.IsTrue(xShipVel == 0);
            Assert.IsTrue(yShipVel == 0);
            Assert.IsTrue(xShipStart == xShip);
            Assert.IsTrue(yShipStart == yShip);

            for (int i = 0; i < 100; i++)
            {
                testShip.Thrust();
            }

            xShipVel = testShip.GetVelocity().GetX();
            yShipVel = testShip.GetVelocity().GetY();

            Assert.IsTrue(xShipVel == 0);
            Assert.AreEqual(yShipVel, 0.08 * -100, 0.000001);

            testShip.Move();

            xShip = testShip.GetLocation().GetX();
            yShip = testShip.GetLocation().GetY();

            Assert.IsTrue(xShipStart + xShipVel == xShip);
            Assert.IsTrue(yShipStart + yShipVel == yShip);
        }