using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; namespace LunaLightXMG { internal class PlayerInput { // Field to store the current keyboard state private KeyboardState currentKeyboardState; // Method to update the input state public void Update() { currentKeyboardState = Keyboard.GetState(); } // Method to check if a key is currently held down public bool IsKeyDown(Keys key) { return currentKeyboardState.IsKeyDown(key); } // Method to check WASD movement keys public Vector2 MoveWithWASD(Vector2 currentPosition, float speed) { Vector2 movement = Vector2.Zero; if (IsKeyDown(Keys.W)) movement.Y -= speed; if (IsKeyDown(Keys.A)) movement.X -= speed; if (IsKeyDown(Keys.S)) movement.Y += speed; if (IsKeyDown(Keys.D)) movement.X += speed; return currentPosition + movement; } } }