Esempio n. 1
0
 /// <summary>
 /// Gets a Vector2 from the directional keys on the keyboard as if they were a thumbstick
 /// </summary>
 /// <returns></returns>
 public static Vector2 GetDirectionalVector()
 {
     //Uses the BoolToInt method to get a directional vector similar to thumbstick rotation
     return(new Vector2(-GameMath.BoolToInt(IsButtonDown(ZuneButtons.Left)) + GameMath.BoolToInt(IsButtonDown(ZuneButtons.Right)),
                        -GameMath.BoolToInt(IsButtonDown(ZuneButtons.Up)) + GameMath.BoolToInt(IsButtonDown(ZuneButtons.Down))));
 }
Esempio n. 2
0
            /// <summary>
            /// Gets a Vector2 from the d-pad on the controller as if it were a thumbstick
            /// </summary>
            /// <returns></returns>
            public static Vector2 GetDPadVector(PlayerIndex playerIndex)
            {
                GamePadState state = GamePad.GetState(playerIndex);

                return(new Vector2(-GameMath.BoolToInt(state.IsButtonDown(Buttons.DPadLeft)) + GameMath.BoolToInt(state.IsButtonDown(Buttons.DPadRight)),
                                   -GameMath.BoolToInt(state.IsButtonDown(Buttons.DPadUp)) + GameMath.BoolToInt(state.IsButtonDown(Buttons.DPadDown))));
            }