mirror of
https://github.com/TheRavenwoodArts/LunaLightXMG.git
synced 2026-07-31 00:15:02 -07:00
Cannot get keyboard input to function still.
This commit is contained in:
+27
-32
@@ -6,6 +6,7 @@ using Microsoft.Xna.Framework.Media;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
namespace LunaLightXMG
|
||||
{
|
||||
@@ -14,8 +15,6 @@ namespace LunaLightXMG
|
||||
// Class Objects
|
||||
private Player player;
|
||||
private PlayerInput playerInput;
|
||||
private List<Enemy> enemies;
|
||||
private int numOfEnemies;
|
||||
private GraphicsDeviceManager graphics;
|
||||
private Camera2D camera2D;
|
||||
private SpriteBatch spriteBatch;
|
||||
@@ -27,44 +26,29 @@ namespace LunaLightXMG
|
||||
// Test Render Target Handler
|
||||
private RenderHandler renderHandler;
|
||||
bool resizing;
|
||||
|
||||
// Test sprites - eventually handle in a sprite manager?
|
||||
private Texture2D platformTexture;
|
||||
private Texture2D sinkArea;
|
||||
|
||||
// Test platforms
|
||||
private Platform[] platforms;
|
||||
private int numOfPlatforms;
|
||||
|
||||
// Level Object
|
||||
private Level level;
|
||||
|
||||
// Music
|
||||
private SoundEffect sinkBeats;
|
||||
private SoundEffectInstance backgroundMusicInstance;
|
||||
// Input
|
||||
// We store our input states so that we only poll once per frame,
|
||||
// then we use the same input state wherever needed
|
||||
private KeyboardState keyboardState;
|
||||
|
||||
// Debugging
|
||||
private SpriteFont debugFont;
|
||||
private Texture2D debugGrid;
|
||||
|
||||
// Keyboard input
|
||||
private KeyboardState prevKeyState;
|
||||
// Util
|
||||
Utilities util;
|
||||
|
||||
public LunaLightGame()
|
||||
{
|
||||
graphics = new GraphicsDeviceManager(this);
|
||||
Content.RootDirectory = "Content";
|
||||
IsMouseVisible = true;
|
||||
|
||||
//Vector2 initPlayerPosition = new Vector2(163,0);
|
||||
//player = new Player(initPlayerPosition);
|
||||
//playerInput = new PlayerInput();
|
||||
|
||||
|
||||
Window.ClientSizeChanged += OnClientSizeChanged;
|
||||
Window.AllowUserResizing = true;
|
||||
IsMouseVisible = true;
|
||||
|
||||
playerInput = new PlayerInput();
|
||||
|
||||
//level = new Level(spriteBatch, renderHandler);
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
@@ -73,8 +57,6 @@ namespace LunaLightXMG
|
||||
graphics.PreferredBackBufferWidth = 1920;
|
||||
graphics.PreferredBackBufferHeight = 1080;
|
||||
graphics.ApplyChanges();
|
||||
|
||||
playerInput.HasControl = true; // May need to find a new home for this
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
@@ -87,24 +69,38 @@ namespace LunaLightXMG
|
||||
if (level != null)
|
||||
level.Dispose();
|
||||
|
||||
level = new Level(spriteBatch, renderHandler);
|
||||
level = new Level(Services, spriteBatch, renderHandler);
|
||||
}
|
||||
|
||||
protected override void Update(GameTime gameTime)
|
||||
{
|
||||
level.Update(gameTime);
|
||||
HandleInput(gameTime);
|
||||
level.Update(gameTime, keyboardState);
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
protected override void Draw(GameTime gameTime)
|
||||
{
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
|
||||
level.Draw(gameTime, spriteBatch);
|
||||
base.Draw(gameTime);
|
||||
}
|
||||
|
||||
#region Methods
|
||||
|
||||
private void HandleInput(GameTime gameTime)
|
||||
{
|
||||
keyboardState = Keyboard.GetState();
|
||||
|
||||
// Temporary quit game - eventually handle in a pause menu class
|
||||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
|
||||
Exit();
|
||||
|
||||
if (keyboardState.IsKeyDown(Keys.R))
|
||||
level.ResetGame();
|
||||
}
|
||||
|
||||
private void OnClientSizeChanged(object sender, EventArgs eventArgs)
|
||||
{
|
||||
if (!resizing && Window.ClientBounds.Width > 0 && Window.ClientBounds.Height > 0)
|
||||
@@ -114,8 +110,7 @@ namespace LunaLightXMG
|
||||
resizing = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user