diff --git a/Level.cs b/Level.cs index d146052..4935620 100644 --- a/Level.cs +++ b/Level.cs @@ -105,6 +105,8 @@ namespace LunaLightXMG player = new Player(initPlayerPosition); playerInput = new PlayerInput(); playerInput.HasControl = true; + // Misc. + prevKeyState = Keyboard.GetState(); player.LoadContent(Content); // Init number of platforms / enemies @@ -126,8 +128,7 @@ namespace LunaLightXMG // Get utilities utilities = new Utilities(); - // Misc. - prevKeyState = Keyboard.GetState(); + } private void LoadPlatforms() @@ -162,7 +163,7 @@ namespace LunaLightXMG ResetGame(); // Update player - playerInput.Update(keyboardState); + playerInput.Update(); player.Update(gameTime, playerInput, platforms); // Update Enemies @@ -276,6 +277,7 @@ namespace LunaLightXMG spriteBatch.DrawString(debugFont, $"Camera Position: {camera2D.Position}", new Vector2(10, 90), Color.White); spriteBatch.DrawString(debugFont, $"Camera Rotation: {camera2D.Rotation}", new Vector2(10, 110), Color.White); spriteBatch.DrawString(debugFont, $"Render Target Zoom: {renderHandler.ZoomLevel}", new Vector2(10, 130), Color.White); + spriteBatch.DrawString(debugFont, $"Key Pressed: {Keyboard.GetState().GetPressedKeys()}", new Vector2(10, 150), Color.White); spriteBatch.DrawString(debugFont, $"Camera Rotation Control - Rotate left: K, Rotate right: L", new Vector2(10, 190), Color.White); spriteBatch.DrawString(debugFont, $"Render Target Zoom Control - Zoom in: U, Zoom normal: I, Zoom out: O", new Vector2(10, 210), Color.White); diff --git a/PlayerInput.cs b/PlayerInput.cs index 33c3e0c..31e1f7d 100644 --- a/PlayerInput.cs +++ b/PlayerInput.cs @@ -18,14 +18,14 @@ namespace LunaLightXMG public bool KeyAttack { get; private set; } public bool KeyWallClimb { get; private set; } - public void Update(KeyboardState keyboardState) + public void Update() { if (HasControl) { if (Controller) { // If using controller, switch to keyboard by pressing any key - if (keyboardState.GetPressedKeys().Length > 0) + if (Keyboard.GetState().GetPressedKeys().Length > 0) { // TODO: Insert logic to create the objMouseJoyStick instance Controller = false; @@ -72,7 +72,7 @@ namespace LunaLightXMG } // Keyboard input - //KeyboardState keyboardState = Keyboard.GetState(); + KeyboardState keyboardState = Keyboard.GetState(); KeyLeft = keyboardState.IsKeyDown(Keys.A) ? 1 : 0; KeyRight = keyboardState.IsKeyDown(Keys.D) ? 1 : 0;