예제 #1
0
        public void TestShipVelocityWith10000FramesOfThrust()
        {
            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 < 10000; i++)
            {
                testShip.Thrust();
            }

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

            Assert.IsTrue(xShipVel == 0);
            Assert.AreEqual(yShipVel, 0.08 * -10000, 0.000001);
        }
예제 #2
0
        public void TestShipVelocityWith1FrameOfThrust()
        {
            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);

            testShip.Thrust();

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

            Assert.IsTrue(xShipVel == 0);
            Assert.IsTrue(yShipVel == 0.08 * -1);

            testWorld.updateShips();

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

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