using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework.Input; using VBXSE; namespace SnakeRPG { public static partial class Main { static KeyboardState oldKeyboardState = Keyboard.GetState(); static KeyboardState newKeyBoardState = Keyboard.GetState(); public static void HandleInput() { oldKeyboardState = newKeyBoardState; newKeyBoardState = Keyboard.GetState(); if (!onTitleScreen) { //Movement if (KeyPressed(Keys.Left) || KeyPressed(Keys.A) || KeyPressed(Keys.NumPad4)) RotateSnake(-1); else if (KeyPressed(Keys.Right) || KeyPressed(Keys.D) || KeyPressed(Keys.NumPad6)) RotateSnake(1); //Dev stuff if (DEBUGMODE) { if (KeyPressed(Keys.P)) { snake.speed += 0.5f; LogVerbose("Speed now " + snake.speed); } if (KeyPressed(Keys.O)) { snake.speed -= 0.5f; LogVerbose("Speed now " + snake.speed); } if (KeyPressed(Keys.Z)) { wallhack = !wallhack; LogVerbose("Wallhack now " + wallhack + "."); } if (KeyPressed(Keys.S)) Save(); if (KeyPressed(Keys.L)) Load(); } } //Title screen if (onTitleScreen) { if (KeyPressed(Keys.Up) || KeyPressed(Keys.W)) TitleScreenMoveSelect(-1); if (KeyPressed(Keys.Down) || KeyPressed(Keys.S)) TitleScreenMoveSelect(1); if (KeyPressed(Keys.Enter) || KeyPressed(Keys.Space) || KeyPressed(Keys.Z)) TitleScreenConfirm(); } //Meta if (KeyPressed(Keys.F) || ((newKeyBoardState.IsKeyDown(Keys.LeftAlt) || newKeyBoardState.IsKeyDown(Keys.RightAlt)) && KeyPressed(Keys.Enter))) SpriteEngine.ToggleFullscreen(); if (KeyPressed(Keys.Escape)) Main.running = false; if (KeyPressed(Keys.Space) && !onTitleScreen) { if (paused) { paused = false; pausedSprite.enabled = false; } else { paused = true; pausedSprite.enabled = true; } } } public static bool KeyPressed(Keys key) { if (newKeyBoardState.IsKeyDown(key) && oldKeyboardState.IsKeyUp(key)) return true; return false; } } }