コード例 #1
0
ファイル: PhysicsGameScreen.cs プロジェクト: jpann/PongBasic
        public override void HandleInput(InputState input, GameTime gameTime)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            // Look up inputs for the active player profile.
            int playerIndex = (int)ControllingPlayer.Value;

            KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex];
            GamePadState gamePadState = input.CurrentGamePadStates[playerIndex];

            if (keyboardState.IsKeyDown(Keys.Home))
            {
                this.mDebugViewXNA.AppendFlags(DebugViewFlags.AABB);
                this.mDebugViewXNA.AppendFlags(DebugViewFlags.CenterOfMass);
                this.mDebugViewXNA.AppendFlags(DebugViewFlags.ContactNormals);
                this.mDebugViewXNA.AppendFlags(DebugViewFlags.ContactPoints);
                this.mDebugViewXNA.AppendFlags(DebugViewFlags.Controllers);
                this.mDebugViewXNA.AppendFlags(DebugViewFlags.DebugPanel);
                this.mDebugViewXNA.AppendFlags(DebugViewFlags.Joint);
                this.mDebugViewXNA.AppendFlags(DebugViewFlags.Pair);
                this.mDebugViewXNA.AppendFlags(DebugViewFlags.PerformanceGraph);
                this.mDebugViewXNA.AppendFlags(DebugViewFlags.PolygonPoints);
                this.mDebugViewXNA.AppendFlags(DebugViewFlags.Shape);
            }

            if (keyboardState.IsKeyDown(Keys.End))
            {
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.AABB);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.CenterOfMass);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.ContactNormals);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.ContactPoints);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.Controllers);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.DebugPanel);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.Joint);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.Pair);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.PerformanceGraph);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.PolygonPoints);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.Shape);
            }

            if (EnableCameraControl)
            {
                HandleCamera(input, gameTime);
            }

            base.HandleInput(input, gameTime);
        }
コード例 #2
0
ファイル: PhysicsGameScreen.cs プロジェクト: jpann/PongBasic
        private void HandleCamera(InputState input, GameTime gameTime)
        {
            // Look up inputs for the active player profile.
            int playerIndex = (int)ControllingPlayer.Value;

            KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex];
            GamePadState gamePadState = input.CurrentGamePadStates[playerIndex];

            Vector2 camMove = Vector2.Zero;

            if (keyboardState.IsKeyDown(Keys.Up))
            {
                camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (keyboardState.IsKeyDown(Keys.Down))
            {
                camMove.Y += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (keyboardState.IsKeyDown(Keys.Left))
            {
                camMove.X -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (keyboardState.IsKeyDown(Keys.Right))
            {
                camMove.X += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (keyboardState.IsKeyDown(Keys.PageUp))
            {
                mCamera.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * mCamera.Zoom / 20f;
            }
            if (keyboardState.IsKeyDown(Keys.PageDown))
            {
                mCamera.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * mCamera.Zoom / 20f;
            }
            if (camMove != Vector2.Zero)
            {
                mCamera.MoveCamera(camMove);
            }
            if (keyboardState.IsKeyDown(Keys.T))
            {
                mCamera.ResetCamera();
            }
            if (keyboardState.IsKeyDown(Keys.R))
            {
                mCamera.Rotation += 1;
            }
            if (keyboardState.IsKeyDown(Keys.F))
            {
                mCamera.Rotation -= 1;
            }
        }