예제 #1
0
    public void TestFixedGameStepTwoUpdates()
    {
        GameFixedUpdate gameFixedUpdate = new GameFixedUpdate();

        gameFixedUpdate.FixedStepTime = 0.05f;

        gameFixedUpdate.Init();

        gameFixedUpdate.Update(0.01f);

        Assert.That(gameFixedUpdate.CurrentGameFrame, Is.EqualTo(0));

        gameFixedUpdate.Update(0.045f);

        Assert.That(gameFixedUpdate.CurrentGameFrame, Is.EqualTo(1));
    }
        public void TestFramesStartsZeroIndexed()
        {
            var gameLogic = new TestGameStep.GameStepEngineMock();

            GameFixedUpdate gameUpdate = new GameFixedUpdate();

            gameUpdate.FixedStepTime = 0.1f;
            gameUpdate.SetGameLogic(gameLogic);

            gameUpdate.Update(0.1f);

            Assert.That(gameLogic.lastFrame, Is.EqualTo(0));

            gameUpdate.Update(0.1f);

            Assert.That(gameLogic.lastFrame, Is.EqualTo(1));
        }
예제 #3
0
    public void TestFixedGameStepGreaterThanFixedTime()
    {
        GameFixedUpdate gameFixedUpdate = new GameFixedUpdate();

        gameFixedUpdate.FixedStepTime = 0.05f;

        gameFixedUpdate.Init();

        gameFixedUpdate.Update(0.051f);

        Assert.That(gameFixedUpdate.CurrentGameFrame, Is.EqualTo(1));
    }
        public void TestNoFixedUpdateIfNotEnoughTime()
        {
            var gameLogic = new TestGameStep.GameStepEngineMock();

            GameFixedUpdate gameUpdate = new GameFixedUpdate();

            gameUpdate.FixedStepTime = 0.1f;
            gameUpdate.SetGameLogic(gameLogic);

            gameUpdate.Update(0.09f);

            Assert.That(gameLogic.UpdateTimes, Is.EqualTo(0));
        }
        public void TestDoubleTimeIncreasesTwoFixedUpdates()
        {
            var gameLogic = new TestGameStep.GameStepEngineMock();

            GameFixedUpdate gameUpdate = new GameFixedUpdate();

            gameUpdate.FixedStepTime = 0.1f;
            gameUpdate.SetGameLogic(gameLogic);

            gameUpdate.Update(0.1f * 2);

            Assert.That(gameLogic.lastFrame, Is.EqualTo(1));
            Assert.That(gameLogic.lastDt, Is.EqualTo(0.1f).Within(0.001f));
        }
예제 #6
0
    public void TestFixedGameStepEngineCalled()
    {
        GameFixedUpdate    gameFixedUpdate = new GameFixedUpdate();
        GameStepEngineMock gameStepEngine  = new GameStepEngineMock();

        gameFixedUpdate.SetGameLogic(gameStepEngine);

        gameFixedUpdate.FixedStepTime = 0.05f;

        gameFixedUpdate.Init();

        gameFixedUpdate.Update(0.078f);

        Assert.That(gameStepEngine.lastDt, Is.EqualTo(0.05f));
        Assert.That(gameStepEngine.lastFrame, Is.EqualTo(0));
    }