/// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input, GameTime gameTime)
        {
            float timeDelta = (float)(gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000.0f);

            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (input.PauseGame)
            {
                // If they pressed pause, bring up the pause menu screen.
                ScreenManager.AddScreen(new PauseMenuScreen());
            }


            m_kPlane.RotX = 0;
            m_kPlane.RotZ = 0;

            if (input.IsKeyHeld(Keys.Up))
            {
                m_kPlane.RotX += -(float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Down))
            {
                m_kPlane.RotX += (float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Left))
            {
                m_kPlane.RotZ += (float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Right))
            {
                m_kPlane.RotZ += -(float)Math.PI / 9;
            }


            //for gamepad input (untested!!)
            //for forward/backward movement
            GamePadState gamePadState = input.CurrentGamePadStates[0];

            m_kPlane.RotX += ((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.Y;
            m_kPlane.RotZ += ((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.Y;

            //for Left/Right movement
            m_kPlane.RotX += ((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.X;
            m_kPlane.RotZ += ((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.X;

            m_kPlane.setRotationOffset(player.position);
        }
Пример #2
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input, GameTime gameTime)
        {
            float timeDelta = (float)(gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000.0f);

            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (input.PauseGame)
            {
                // If they pressed pause, bring up the pause menu screen.
                ScreenManager.AddScreen(new PauseMenuScreen());
            }


            m_kPlane.RotX = 0;
            m_kPlane.RotZ = 0;
            if (input.IsKeyHeld(Keys.Up))
            {
                m_kPlane.RotX += -(float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Down))
            {
                m_kPlane.RotX += (float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Left))
            {
                m_kPlane.RotZ += (float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Right))
            {
                m_kPlane.RotZ += -(float)Math.PI / 9;
            }


            m_kPlane.setRotationOffset(player.position);


            /*
             * //OLD SHIP FUNCTIONS
             * player.rotationVelocity = 0;
             * if (input.ShipTurnLeft)
             * {
             *  player.rotationVelocity += 3;
             * }
             * if (input.ShipTurnRight)
             * {
             *  player.rotationVelocity += -3;
             * }
             * Vector3 thrust = Vector3.Zero;
             * if (input.ShipMove)
             * {
             *  thrust += 3500f * player.directionVec;
             * }
             * if (input.ReverseThrust)
             * {
             *  thrust += -3500f * player.directionVec;
             * }
             * player.netForce = thrust;
             */
        }
Пример #3
0
        /// <summary>
        /// Collision resolution. Kind of a hack.
        /// Called from the Update function
        /// Tweak numbers until the feel is "right"
        /// </summary>
        /// <param name="pushAway">The normalized vector that the ball should be pushed away</param>
        /// <param name="timeDelta"></param>
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input, GameTime gameTime)
        {
            float timeDelta = (float)(gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000.0f);

            if (input == null)
                throw new ArgumentNullException("input");

            if (input.PauseGame)
            {
                // If they pressed pause, bring up the pause menu screen.
                ScreenManager.AddScreen(new PauseMenuScreen());
            }

            float RotX = 0;
            float RotZ = 0;
            //The axis are flipped from what would be expected
            //If you want to go forward/backwards, you need to switch Z and X
            //If you want to go Left/Right you keep Z and X consistent
            if (input.IsKeyHeld(Keys.Up))
            {
                RotX += ((float)Math.PI / 9) * m_kLookingDir.Z;
                RotZ += -((float)Math.PI / 9) * m_kLookingDir.X;
            }
            if (input.IsKeyHeld(Keys.Down))
            {
                RotX += -((float)Math.PI / 9) * m_kLookingDir.Z;
                RotZ += ((float)Math.PI / 9) * m_kLookingDir.X;
            }
            if (input.IsKeyHeld(Keys.Left))
            {
                RotX += -((float)Math.PI / 9) * m_kLookingDir.X;
                RotZ += -((float)Math.PI / 9) * m_kLookingDir.Z;
            }
            if (input.IsKeyHeld(Keys.Right))
            {
                RotX += ((float)Math.PI / 9) * m_kLookingDir.X;
                RotZ += ((float)Math.PI / 9) * m_kLookingDir.Z;
            }

            //Manually changing the camera rotation based on user input
            if (input.IsADown)
            {
                manualCameraRotation += (float)Math.PI / 4 * (float)gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000;
            }
            if (input.IsDDown)
            {
                manualCameraRotation -= (float)Math.PI / 4 * (float)gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000;
            }

            //camera rotation for 360 controller
            GamePadState gamePadState = input.CurrentGamePadStates[0];
            manualCameraRotation += (float)Math.PI / 4 * gamePadState.ThumbSticks.Right.X * timeDelta * 5;
            gameCamera.ManualCameraRotation(manualCameraRotation, player);

            //for forward/backward movement
            //GamePadState gamePadState = input.CurrentGamePadStates[0];
               // RotX += ((float)Math.PI / 9) * m_kLookingDir.Z;
               // RotZ += -((float)Math.PI / 9) * m_kLookingDir.X;

            RotX += ((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.Y;
            RotZ += -((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.Y;

            //for Left/Right movement
            RotX += ((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.X;
            RotZ += ((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.X;

            activeLevel.setRotation(RotX, RotZ, player.position);
        }
Пример #4
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input, GameTime gameTime)
        {
            float timeDelta = (float)(gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000.0f);

            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (input.PauseGame)
            {
                // If they pressed pause, bring up the pause menu screen.
                ScreenManager.AddScreen(new PauseMenuScreen());
            }


            //Manually changing the camera rotation based on user input
            if (input.IsADown)
            {
                manualCameraRotation += (float)Math.PI / 4 * (float)gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000;
            }
            if (input.IsDDown)
            {
                manualCameraRotation -= (float)Math.PI / 4 * (float)gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000;
            }

            //camera rotation for 360 controller
            GamePadState gamePadState = input.CurrentGamePadStates[0];

            manualCameraRotation += (float)Math.PI / 4 * gamePadState.ThumbSticks.Right.X * timeDelta * 5;
            gameCamera.ManualCameraRotation(manualCameraRotation, player);


            foreach (LevelPiece p in planes)
            {
                p.RotX = 0;
                p.RotZ = 0;
                //The axis are flipped from what would be expected
                //If you want to go forward/backwards, you need to switch Z and X
                //If you want to go Left/Right you keep Z and X consistent
                if (input.IsKeyHeld(Keys.Up))
                {
                    p.RotX += ((float)Math.PI / 9) * m_kLookingDir.Z;
                    p.RotZ += -((float)Math.PI / 9) * m_kLookingDir.X;
                }
                if (input.IsKeyHeld(Keys.Down))
                {
                    p.RotX += -((float)Math.PI / 9) * m_kLookingDir.Z;
                    p.RotZ += ((float)Math.PI / 9) * m_kLookingDir.X;
                }
                if (input.IsKeyHeld(Keys.Left))
                {
                    p.RotX += -((float)Math.PI / 9) * m_kLookingDir.X;
                    p.RotZ += -((float)Math.PI / 9) * m_kLookingDir.Z;
                }
                if (input.IsKeyHeld(Keys.Right))
                {
                    p.RotX += ((float)Math.PI / 9) * m_kLookingDir.X;
                    p.RotZ += ((float)Math.PI / 9) * m_kLookingDir.Z;
                }


                //for forward/backward movement
                //GamePadState gamePadState = input.CurrentGamePadStates[0];
                p.RotX += ((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.Y;
                p.RotZ += ((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.Y;

                //for Left/Right movement
                p.RotX += ((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.X;
                p.RotZ += ((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.X;


                p.setRotationOffset(player.position);
            }
        }
Пример #5
0
        /// <summary>
        /// Collision resolution. Kind of a hack.
        /// Called from the Update function
        /// Tweak numbers until the feel is "right"
        /// </summary>
        /// <param name="pushAway">The normalized vector that the ball should be pushed away</param>
        /// <param name="timeDelta"></param>
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input, GameTime gameTime)
        {
            float timeDelta = (float)(gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000.0f);

            if (input == null)
                throw new ArgumentNullException("input");

            if (input.PauseGame)
            {
                // If they pressed pause, bring up the pause menu screen.
                ScreenManager.AddScreen(new PauseMenuScreen());
            }

            float RotX = 0;
            float RotZ = 0;
            if (input.IsKeyHeld(Keys.Up))
            {
                RotX += -(float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Down))
            {
                RotX += (float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Left))
            {
                RotZ += (float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Right))
            {
                RotZ += -(float)Math.PI / 9;
            }

            activeLevel.setRotation(RotX, RotZ, player.position);
            /*
            //OLD SHIP FUNCTIONS
            player.rotationVelocity = 0;
            if (input.ShipTurnLeft)
            {
                player.rotationVelocity += 3;
            }
            if (input.ShipTurnRight)
            {
                player.rotationVelocity += -3;
            }
            Vector3 thrust = Vector3.Zero;
            if (input.ShipMove)
            {
                thrust += 3500f * player.directionVec;
            }
            if (input.ReverseThrust)
            {
                thrust += -3500f * player.directionVec;
            }
            player.netForce = thrust;
            */
        }
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input, GameTime gameTime)
        {
            float timeDelta = (float)(gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000.0f);

            if (input == null)
                throw new ArgumentNullException("input");

            if (input.PauseGame)
            {
                // If they pressed pause, bring up the pause menu screen.
                ScreenManager.AddScreen(new PauseMenuScreen());
            }

            m_kPlane.RotX = 0;
            m_kPlane.RotZ = 0;

            if(input.IsKeyHeld(Keys.Up)) {
                m_kPlane.RotX += -(float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Down))
            {
                m_kPlane.RotX += (float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Left))
            {
                m_kPlane.RotZ += (float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Right))
            {
                m_kPlane.RotZ += -(float)Math.PI / 9;
            }

               //for gamepad input (untested!!)
               //for forward/backward movement
               GamePadState gamePadState = input.CurrentGamePadStates[0];
               m_kPlane.RotX += ((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.Y;
               m_kPlane.RotZ += ((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.Y;

               //for Left/Right movement
               m_kPlane.RotX += ((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.X;
               m_kPlane.RotZ += ((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.X;

            m_kPlane.setRotationOffset(player.position);
        }
Пример #7
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input, GameTime gameTime)
        {
            float timeDelta = (float)(gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000.0f);

            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (input.PauseGame)
            {
                // If they pressed pause, bring up the pause menu screen.
                ScreenManager.AddScreen(new PauseMenuScreen());
            }


            m_kPlane.RotX = 0;
            m_kPlane.RotZ = 0;
            Vector3 m_kLookingDir = player.position - gameCamera.GetCameraPosition();

            m_kLookingDir.Y = 0f;
            m_kLookingDir.Normalize();
            //m_kLookingDir = new Vector3(-1f, 0, 0);

            //The axis are flipped from what would be expected
            //If you want to go forward/backwards, you need to switch Z and X
            //If you want to go Left/Right you keep Z and X consistent
            if (input.IsKeyHeld(Keys.Up))
            {
                m_kPlane.RotX += ((float)Math.PI / 9) * m_kLookingDir.Z;
                m_kPlane.RotZ += -((float)Math.PI / 9) * m_kLookingDir.X;
            }
            if (input.IsKeyHeld(Keys.Down))
            {
                m_kPlane.RotX += -((float)Math.PI / 9) * m_kLookingDir.Z;
                m_kPlane.RotZ += ((float)Math.PI / 9) * m_kLookingDir.X;
            }
            if (input.IsKeyHeld(Keys.Left))
            {
                m_kPlane.RotX += -((float)Math.PI / 9) * m_kLookingDir.X;
                m_kPlane.RotZ += -((float)Math.PI / 9) * m_kLookingDir.Z;
            }
            if (input.IsKeyHeld(Keys.Right))
            {
                m_kPlane.RotX += ((float)Math.PI / 9) * m_kLookingDir.X;
                m_kPlane.RotZ += ((float)Math.PI / 9) * m_kLookingDir.Z;
            }

            /*
             * //for gamepad input (untested!!)
             * //for forward/backward movement
             * GamePadState gamePadState = input.CurrentGamePadStates[0];
             * m_kPlane.RotX += ((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.Y;
             * m_kPlane.RotZ += -((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.Y;
             *
             * //for Left/Right movement
             * m_kPlane.RotX += -((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.X;
             * m_kPlane.RotZ += -((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.X;
             */

            m_kPlane.setRotationOffset(player.position);

            //Manually changing the camera rotation based on user input

            if (input.IsADown)
            {
                manualCameraRotation += (float)Math.PI / 4 * (float)gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000;
            }
            if (input.IsDDown)
            {
                manualCameraRotation -= (float)Math.PI / 4 * (float)gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000;
            }

            gameCamera.ManualCameraRotation(manualCameraRotation, player);

            /*
             * //OLD SHIP FUNCTIONS
             * player.rotationVelocity = 0;
             * if (input.ShipTurnLeft)
             * {
             *  player.rotationVelocity += 3;
             * }
             * if (input.ShipTurnRight)
             * {
             *  player.rotationVelocity += -3;
             * }
             * Vector3 thrust = Vector3.Zero;
             * if (input.ShipMove)
             * {
             *  thrust += 3500f * player.directionVec;
             * }
             * if (input.ReverseThrust)
             * {
             *  thrust += -3500f * player.directionVec;
             * }
             * player.netForce = thrust;
             */
        }
Пример #8
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input, GameTime gameTime)
        {
            float timeDelta = (float)(gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000.0f);

            if (input == null)
                throw new ArgumentNullException("input");

            if (input.PauseGame)
            {
                // If they pressed pause, bring up the pause menu screen.
                ScreenManager.AddScreen(new PauseMenuScreen());
            }

            m_kPlane.RotX = 0;
            m_kPlane.RotZ = 0;
            Vector3 m_kLookingDir = player.position - gameCamera.GetCameraPosition();
            m_kLookingDir.Y = 0f;
            m_kLookingDir.Normalize();
            //m_kLookingDir = new Vector3(-1f, 0, 0);

            //The axis are flipped from what would be expected
            //If you want to go forward/backwards, you need to switch Z and X
            //If you want to go Left/Right you keep Z and X consistent
            if (input.IsKeyHeld(Keys.Up))
            {

                m_kPlane.RotX +=  ((float)Math.PI / 9) * m_kLookingDir.Z;
                m_kPlane.RotZ += -((float)Math.PI / 9) * m_kLookingDir.X;

            }
            if (input.IsKeyHeld(Keys.Down))
            {
                m_kPlane.RotX += -((float)Math.PI / 9) * m_kLookingDir.Z;
                m_kPlane.RotZ +=  ((float)Math.PI / 9) * m_kLookingDir.X;
            }
            if (input.IsKeyHeld(Keys.Left))
            {
                m_kPlane.RotX += -((float)Math.PI / 9) * m_kLookingDir.X;
                m_kPlane.RotZ += -((float)Math.PI / 9) * m_kLookingDir.Z;
            }
            if (input.IsKeyHeld(Keys.Right))
            {
                m_kPlane.RotX +=  ((float)Math.PI / 9) * m_kLookingDir.X;
                m_kPlane.RotZ +=  ((float)Math.PI / 9) * m_kLookingDir.Z;
            }

            /*
            //for gamepad input (untested!!)
            //for forward/backward movement
            GamePadState gamePadState = input.CurrentGamePadStates[0];
            m_kPlane.RotX += ((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.Y;
            m_kPlane.RotZ += -((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.Y;

            //for Left/Right movement
            m_kPlane.RotX += -((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.X;
            m_kPlane.RotZ += -((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.X;
            */

            m_kPlane.setRotationOffset(player.position);

            //Manually changing the camera rotation based on user input

            if (input.IsADown)
            {
                manualCameraRotation += (float)Math.PI / 4 * (float)gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000;
            }
            if (input.IsDDown)
            {
                manualCameraRotation -= (float)Math.PI / 4 * (float)gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000;
            }

            gameCamera.ManualCameraRotation(manualCameraRotation, player);

            /*
            //OLD SHIP FUNCTIONS
            player.rotationVelocity = 0;
            if (input.ShipTurnLeft)
            {
                player.rotationVelocity += 3;
            }
            if (input.ShipTurnRight)
            {
                player.rotationVelocity += -3;
            }
            Vector3 thrust = Vector3.Zero;
            if (input.ShipMove)
            {
                thrust += 3500f * player.directionVec;
            }
            if (input.ReverseThrust)
            {
                thrust += -3500f * player.directionVec;
            }
            player.netForce = thrust;
            */
        }