Exemplo n.º 1
0
        // ===============================================================================
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            //GameSettings.ScreenHeight = gameConfig.PreferredHeight;
            //GameSettings.ScreenWidth = gameConfig.PreferredWidth;

            graphics.PreferredBackBufferWidth = 1600;
            graphics.PreferredBackBufferHeight = 1024;

            //graphics.ToggleFullScreen();
            graphics.ApplyChanges();

            Mouse.SetPosition(graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height / 2);

            input = new InputHandler(this);
            Components.Add(input);
        }
Exemplo n.º 2
0
 // ================================================================================
 public bool WasPressed(int playerIndex, InputHandler.ButtonType buttonType, Keys keys)
 {
     if (gamePadHandler.WasButtonPressed(playerIndex, buttonType) || keyboard.WasKeyPressed(keys))
         return (true);
     else
         return (false);
 }
Exemplo n.º 3
0
        public bool WasButtonPressed(int playerIndex, InputHandler.ButtonType button)
        {
            int pi = playerIndex;
            switch (button)
            { //start switch
                case InputHandler.ButtonType.A:
                    {
                        return (gamePadsState[pi].Buttons.A == ButtonState.Pressed && prevGamePadsState[pi].Buttons.A == ButtonState.Released);
                    }
                case InputHandler.ButtonType.B:
                    {
                        return (gamePadsState[pi].Buttons.B == ButtonState.Pressed && prevGamePadsState[pi].Buttons.B == ButtonState.Released);
                    }
                case InputHandler.ButtonType.Back:
                    {
                        return (gamePadsState[pi].Buttons.Back == ButtonState.Pressed && prevGamePadsState[pi].Buttons.Back == ButtonState.Released);
                    }
                case InputHandler.ButtonType.LeftShoulder:
                    {
                        return (gamePadsState[pi].Buttons.LeftShoulder == ButtonState.Pressed && prevGamePadsState[pi].Buttons.LeftShoulder == ButtonState.Released);
                    }
                case InputHandler.ButtonType.LeftStick:
                    {
                        return (gamePadsState[pi].Buttons.LeftStick == ButtonState.Pressed && prevGamePadsState[pi].Buttons.LeftStick == ButtonState.Released);
                    }
                case InputHandler.ButtonType.RightShoulder:
                    {
                        return (gamePadsState[pi].Buttons.RightShoulder == ButtonState.Pressed && prevGamePadsState[pi].Buttons.RightShoulder == ButtonState.Released);
                    }
                case InputHandler.ButtonType.RightStick:
                    {
                        return (gamePadsState[pi].Buttons.RightStick == ButtonState.Pressed && prevGamePadsState[pi].Buttons.RightStick == ButtonState.Released);
                    }
                case InputHandler.ButtonType.Start:
                    {
                        return (gamePadsState[pi].Buttons.Start == ButtonState.Pressed && prevGamePadsState[pi].Buttons.Start == ButtonState.Released);
                    }
                case InputHandler.ButtonType.X:
                    {
                        return (gamePadsState[pi].Buttons.X == ButtonState.Pressed && prevGamePadsState[pi].Buttons.X == ButtonState.Released);
                    }
                case InputHandler.ButtonType.Y:
                    {
                        return (gamePadsState[pi].Buttons.Y == ButtonState.Pressed && prevGamePadsState[pi].Buttons.Y == ButtonState.Released);
                    }

                default:
                    throw (new ArgumentException());

            } //end switch
        }