Esempio n. 1
0
        public void Update()
        {
            var entities = Scene.GetEntities(_ => MatchActiveEntitiesAndComponents(_));

            if (Scene.Gravity != default && Scene.Gravity != _world.Gravity)
            {
                _world.Gravity = Scene.Gravity;
            }

            if (entities.Any() && entities.Count != _world.BodyList.Count)
            {
                LoadContent();
            }

            for (int i = 0; i < entities.Count(); i++)
            {
                var entity        = entities.ElementAt(i);
                var bodyComponent = entity.GetComponent <BodyComponent>();

                bodyComponent.Enabled = entity.Active;

                entity.SetPosition(bodyComponent.Position);
                entity.SetRotation(MathHelper.ToDegrees(bodyComponent.Rotation));
            }

            _world.Step(Scene.DeltaTime);

            if (Scene.GameCore.DebugActive && entities.Any())
            {
                _debugView.UpdatePerformanceGraph(_world.UpdateTime);
            }
        }
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            if (!coveredByOtherScreen && !otherScreenHasFocus)
            {
                // variable time step but never less then 30 Hz
                World.Step(Math.Min((float)gameTime.ElapsedGameTime.TotalSeconds, (1f / 30f)));
            }

            Camera.Update(gameTime);
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

            DebugView.UpdatePerformanceGraph(World.UpdateTime);
        }
Esempio n. 3
0
        /// <summary>
        /// Aktualizace scény mezi jednotlivými grafickými vykresleními.
        /// </summary>
        /// <param name="currentKeyboardState">Aktuální stav klávesnice.</param>
        /// <param name="previousKeyboardState">Předchozí stav klávesnice.</param>
        /// <param name="currentGamePadState">Aktuální stav herního ovladače.</param>
        /// <param name="previousGamePadState">Předchozí stav herního ovladače.</param>
        public virtual void Update(
            KeyboardState currentKeyboardState,
            KeyboardState previousKeyboardState,
            GamePadState currentGamePadState,
            GamePadState previousGamePadState)
        {
            DebugView.UpdatePerformanceGraph(Demo.World3D.World2D.UpdateTime);

            if (DemoHelper.PressedOnce(Keys.F1, currentKeyboardState, previousKeyboardState))
            {
                EnableOrDisableFlag(DebugViewFlags.Shape);
            }
            if (DemoHelper.PressedOnce(Keys.F2, currentKeyboardState, previousKeyboardState))
            {
                EnableOrDisableFlag(DebugViewFlags.DebugPanel);
                EnableOrDisableFlag(DebugViewFlags.PerformanceGraph);
            }
            if (DemoHelper.PressedOnce(Keys.F3, currentKeyboardState, previousKeyboardState))
            {
                EnableOrDisableFlag(DebugViewFlags.Joint);
            }
            if (DemoHelper.PressedOnce(Keys.F4, currentKeyboardState, previousKeyboardState))
            {
                EnableOrDisableFlag(DebugViewFlags.ContactPoints);
                EnableOrDisableFlag(DebugViewFlags.ContactNormals);
            }
            if (DemoHelper.PressedOnce(Keys.F5, currentKeyboardState, previousKeyboardState))
            {
                EnableOrDisableFlag(DebugViewFlags.PolygonPoints);
            }
            if (DemoHelper.PressedOnce(Keys.F6, currentKeyboardState, previousKeyboardState))
            {
                EnableOrDisableFlag(DebugViewFlags.Controllers);
            }
            if (DemoHelper.PressedOnce(Keys.F7, currentKeyboardState, previousKeyboardState))
            {
                EnableOrDisableFlag(DebugViewFlags.CenterOfMass);
            }
            if (DemoHelper.PressedOnce(Keys.F8, currentKeyboardState, previousKeyboardState))
            {
                EnableOrDisableFlag(DebugViewFlags.AABB);
            }
        }