Пример #1
0
        public void Update()
        {
            var time = _timer.GetTime();

            foreach (var layer in _layers)
            {
                LayerExtensions.UpdateLayer(layer, time);
            }
        }
Пример #2
0
        public void Run()
        {
            double previousTime = timer.GetTime();
            double lag          = 0;

            while (game.Running)
            {
                double currentTime = timer.GetTime();
                lag += currentTime - previousTime;

                while (lag >= FrameTime)
                {
                    game.Update(inputHandler.CurrentInput);
                    lag -= FrameTime;
                }
                game.Render();

                previousTime = currentTime;
            }
        }
Пример #3
0
        public GameLoopTest()
        {
            testGame         = A.Fake <IGame <TestInput> >();
            testInputHandler = A.Fake <InputHandler <TestInput> >();
            testTimer        = A.Fake <ITimer>();

            double time = 0.0;

            A.CallTo(() => testTimer.GetTime()).ReturnsLazily(() => time++);

            gameLoop = new GameLoop <TestInput>(testGame, testInputHandler, testTimer)
            {
                FrameTime = 1.0
            };
        }