Пример #1
0
        /// <summary>
        /// This method runs on every frame
        /// </summary>
        private void GameLoop()
        {
            // Close program with esc
            if (InputDevice.Keyboard.IsKeyDown(VirtualKeyCode.ESCAPE))
            {
                renderForm.Dispose();
            }

            stopwatch.Restart();

            // Execute all Update methods
            StaticUpdater.ExecuteUpdateActions(lastDeltaTime);

            // Render on each frame
            renderDevice.Draw();

            foreach (GameObject gameObject in Scene.CurrentScene.GameObjects)
            {
                // Execute updates per-object
                foreach (IComponent component in gameObject.Components)
                {
                    component.Update(lastDeltaTime);
                }
            }

            // TODO create separate physics loop
            PhysicsHandler.Simulation.Timestep(lastDeltaTime);

            stopwatch.Stop();
            lastDeltaTime = (float)stopwatch.Elapsed.TotalSeconds;
            elapsedTime  += lastDeltaTime;
        }