Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static class Input {
- public static bool IsKeyPressed(Key key) {
- int index = (int)key;
- return KeysDown[index] && !keysDownPrevious[index];
- }
- public static bool IsMousePressed(MouseButton mouseButton) {
- int index = (int)mouseButton;
- return MouseButtonsDown[index] && !mouseButtonsDownPrevious[index];
- }
- private static readonly byte AmountOfKeys = (byte)Enum.GetNames(typeof(Key)).Length;
- private static readonly byte AmountOfMouseButtons = (byte)Enum.GetNames(typeof(MouseButton)).Length;
- public static void Handle() {
- for (byte index = 0; index < AmountOfKeys - 1; index += 1) {
- keysDownPrevious[index] = KeysDown[index];
- }
- for (byte index = 0; index < AmountOfMouseButtons - 1; index += 1) {
- mouseButtonsDownPrevious[index] = MouseButtonsDown[index];
- }
- }
- public static bool[] KeysDown = new bool[AmountOfKeys];
- public static bool[] MouseButtonsDown = new bool[AmountOfKeys];
- private static bool[] keysDownPrevious = new bool[AmountOfKeys];
- private static bool[] mouseButtonsDownPrevious = new bool[AmountOfMouseButtons];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement