Example #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (inputHandler.KeyboardManager.KeyPress(Keys.Escape))
            {
                this.Exit();
            }

            float x = (float)Math.Cos(gameTime.TotalGameTime.TotalSeconds) * 10;
            float y = 1;// MathHelper.Clamp((float)Math.Cos(gameTime.TotalGameTime.TotalSeconds), 0, 1);
            float z = (float)Math.Sin(gameTime.TotalGameTime.TotalSeconds) * 10;

            Vector3 lp = tailInstancer.Position;

            tailInstancer.Position = new Vector3(x, y, z - 10);
            GameComponentHelper.LookAt(lp, 1, tailInstancer.Position, ref tailInstancer.Rotation, Vector3.Down);

            float speedTran = .1f;
            float speedRot  = .01f;

            if (inputHandler.KeyboardManager.KeyPress(Keys.F1))
            {
                renderer.DebugDeferred = !renderer.DebugDeferred;
            }

            if (inputHandler.KeyboardManager.KeyPress(Keys.Space))
            {
                renderer.DirectionalLights[0].CastShadow = !renderer.DirectionalLights[0].CastShadow;
            }

            if (inputHandler.KeyboardManager.KeyDown(Keys.W) || inputHandler.GamePadManager.ButtonDown(PlayerIndex.One, Buttons.DPadUp))
            {
                camera.Translate(Vector3.Forward * speedTran);
            }
            if (inputHandler.KeyboardManager.KeyDown(Keys.S) || inputHandler.GamePadManager.ButtonDown(PlayerIndex.One, Buttons.DPadDown))
            {
                camera.Translate(Vector3.Backward * speedTran);
            }
            if (inputHandler.KeyboardManager.KeyDown(Keys.A) || inputHandler.GamePadManager.ButtonDown(PlayerIndex.One, Buttons.DPadLeft))
            {
                camera.Translate(Vector3.Left * speedTran);
            }
            if (inputHandler.KeyboardManager.KeyDown(Keys.D) || inputHandler.GamePadManager.ButtonDown(PlayerIndex.One, Buttons.DPadRight))
            {
                camera.Translate(Vector3.Right * speedTran);
            }

            if (inputHandler.KeyboardManager.KeyDown(Keys.Left) || inputHandler.GamePadManager.State[PlayerIndex.One].ThumbSticks.Right.X < 0)
            {
                camera.Rotate(Vector3.Up, speedRot);
            }
            if (inputHandler.KeyboardManager.KeyDown(Keys.Right) || inputHandler.GamePadManager.State[PlayerIndex.One].ThumbSticks.Right.X > 0)
            {
                camera.Rotate(Vector3.Up, -speedRot);
            }
            if (inputHandler.KeyboardManager.KeyDown(Keys.Up) || inputHandler.GamePadManager.State[PlayerIndex.One].ThumbSticks.Right.Y > 0)
            {
                camera.Rotate(Vector3.Right, speedRot);
            }
            if (inputHandler.KeyboardManager.KeyDown(Keys.Down) || inputHandler.GamePadManager.State[PlayerIndex.One].ThumbSticks.Right.Y < 0)
            {
                camera.Rotate(Vector3.Right, -speedRot);
            }

            if (inputHandler.KeyboardManager.KeyPress(Keys.F2))
            {
                snowInstancer.Enabled = !snowInstancer.Enabled;
            }

            if (inputHandler.KeyboardManager.KeyPress(Keys.F3))
            {
                tailInstancer.Enabled = !tailInstancer.Enabled;
            }

            if (inputHandler.KeyboardManager.KeyPress(Keys.F4))
            {
                smokeInstancer.Enabled = !smokeInstancer.Enabled;
            }


            box.Rotate(Vector3.Up, .01f);
            box1.Rotate(Vector3.Up + Vector3.Left, .01f);
            box2.Rotate(Vector3.Left, .01f);

            base.Update(gameTime);
        }
Example #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (inputHandler.KeyboardManager.KeyPress(Keys.Escape))
            {
                this.Exit();
            }

            float speedTran = .1f;
            float speedRot  = .01f;

            if (inputHandler.KeyboardManager.KeyPress(Keys.F1))
            {
                renderer.DebugDeferred = !renderer.DebugDeferred;
            }

            if (inputHandler.KeyboardManager.KeyPress(Keys.Space))
            {
                renderer.DirectionalLights[0].CastShadow = !renderer.DirectionalLights[0].CastShadow;
            }

            if (inputHandler.KeyboardManager.KeyDown(Keys.W) || inputHandler.GamePadManager.ButtonDown(PlayerIndex.One, Buttons.DPadUp))
            {
                camera.Translate(Vector3.Forward * speedTran);
            }
            if (inputHandler.KeyboardManager.KeyDown(Keys.S) || inputHandler.GamePadManager.ButtonDown(PlayerIndex.One, Buttons.DPadDown))
            {
                camera.Translate(Vector3.Backward * speedTran);
            }
            if (inputHandler.KeyboardManager.KeyDown(Keys.A) || inputHandler.GamePadManager.ButtonDown(PlayerIndex.One, Buttons.DPadLeft))
            {
                camera.Translate(Vector3.Left * speedTran);
            }
            if (inputHandler.KeyboardManager.KeyDown(Keys.D) || inputHandler.GamePadManager.ButtonDown(PlayerIndex.One, Buttons.DPadRight))
            {
                camera.Translate(Vector3.Right * speedTran);
            }

            if (inputHandler.KeyboardManager.KeyDown(Keys.Left) || inputHandler.GamePadManager.State[PlayerIndex.One].ThumbSticks.Right.X < 0)
            {
                camera.Rotate(Vector3.Up, speedRot);
            }
            if (inputHandler.KeyboardManager.KeyDown(Keys.Right) || inputHandler.GamePadManager.State[PlayerIndex.One].ThumbSticks.Right.X > 0)
            {
                camera.Rotate(Vector3.Up, -speedRot);
            }
            if (inputHandler.KeyboardManager.KeyDown(Keys.Up) || inputHandler.GamePadManager.State[PlayerIndex.One].ThumbSticks.Right.Y > 0)
            {
                camera.Rotate(Vector3.Right, speedRot);
            }
            if (inputHandler.KeyboardManager.KeyDown(Keys.Down) || inputHandler.GamePadManager.State[PlayerIndex.One].ThumbSticks.Right.Y < 0)
            {
                camera.Rotate(Vector3.Right, -speedRot);
            }

            box.Rotate(Vector3.Up, .01f);
            box1.Rotate(Vector3.Up + Vector3.Left, .01f);
            box2.Rotate(Vector3.Left, .01f);

            base.Update(gameTime);
        }