|
@ -4,29 +4,40 @@ using Microsoft.Xna.Framework.Input; |
|
|
namespace SemiColinGames { |
|
|
namespace SemiColinGames { |
|
|
public readonly struct Input { |
|
|
public readonly struct Input { |
|
|
public readonly Vector2 Motion; |
|
|
public readonly Vector2 Motion; |
|
|
|
|
|
// If true, the player's x-motion should be treated as an absolute number of pixels in a given
|
|
|
|
|
|
// direction, regardless of modeled time. This is only enabled in DEBUG builds.
|
|
|
|
|
|
public readonly bool IsAbsoluteMotion; |
|
|
public readonly bool Jump; |
|
|
public readonly bool Jump; |
|
|
public readonly bool Attack; |
|
|
public readonly bool Attack; |
|
|
|
|
|
|
|
|
public readonly bool Pause; |
|
|
public readonly bool Pause; |
|
|
public readonly bool Debug; |
|
|
public readonly bool Debug; |
|
|
|
|
|
// Button combos for Exit / Restart / FullScreen only work in DEBUG builds.
|
|
|
|
|
|
// Keyboard controls always work for these actions.
|
|
|
public readonly bool Exit; |
|
|
public readonly bool Exit; |
|
|
public readonly bool Restart; |
|
|
public readonly bool Restart; |
|
|
public readonly bool FullScreen; |
|
|
public readonly bool FullScreen; |
|
|
|
|
|
|
|
|
public Input(GamePadState gamePad, KeyboardState keyboard) { |
|
|
public Input(GamePadState gamePad, KeyboardState keyboard) { |
|
|
Motion = new Vector2(); |
|
|
Motion = new Vector2(); |
|
|
|
|
|
IsAbsoluteMotion = false; |
|
|
|
|
|
|
|
|
// We check for debugging buttons first. If any are pressed, we suppress normal input;
|
|
|
// We check for debugging buttons first. If any are pressed, we suppress normal input;
|
|
|
// other button-presses correspond to special debugging things.
|
|
|
// other button-presses correspond to special debugging things.
|
|
|
Exit = keyboard.IsKeyDown(Keys.Escape); |
|
|
Exit = keyboard.IsKeyDown(Keys.Escape); |
|
|
Restart = keyboard.IsKeyDown(Keys.F5); |
|
|
Restart = keyboard.IsKeyDown(Keys.F5); |
|
|
FullScreen = keyboard.IsKeyDown(Keys.F12); |
|
|
FullScreen = keyboard.IsKeyDown(Keys.F12); |
|
|
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
if (gamePad.IsButtonDown(Buttons.LeftShoulder) && |
|
|
if (gamePad.IsButtonDown(Buttons.LeftShoulder) && |
|
|
gamePad.IsButtonDown(Buttons.RightShoulder)) { |
|
|
gamePad.IsButtonDown(Buttons.RightShoulder)) { |
|
|
|
|
|
IsAbsoluteMotion = true; |
|
|
Exit |= gamePad.IsButtonDown(Buttons.Start); |
|
|
Exit |= gamePad.IsButtonDown(Buttons.Start); |
|
|
Restart |= gamePad.IsButtonDown(Buttons.Back); |
|
|
Restart |= gamePad.IsButtonDown(Buttons.Back); |
|
|
FullScreen |= gamePad.IsButtonDown(Buttons.Y); |
|
|
FullScreen |= gamePad.IsButtonDown(Buttons.Y); |
|
|
} |
|
|
} |
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
if (Exit || Restart || FullScreen) { |
|
|
if (Exit || Restart || FullScreen) { |
|
|
Jump = false; |
|
|
Jump = false; |
|
|
Attack = false; |
|
|
Attack = false; |
|
@ -67,6 +78,7 @@ namespace SemiColinGames { |
|
|
if (down && !up) { |
|
|
if (down && !up) { |
|
|
Motion.Y = -1; |
|
|
Motion.Y = -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |