mirror of
https://github.com/TheRavenwoodArts/LunaLightXMG.git
synced 2026-07-30 22:55:03 -07:00
Added a simple player input class to test abstraction.
This commit is contained in:
@@ -21,6 +21,11 @@ namespace LunaLightXMG
|
||||
Texture2D sprCave1_foreground;
|
||||
Texture2D sprCave1_walls;
|
||||
|
||||
// Test player input and movement with abstracted player input class
|
||||
private PlayerInput playerInput;
|
||||
private Vector2 objectPosition;
|
||||
private float movementSpeed = 100f; // Movement speed in pixels per second
|
||||
|
||||
// Native retro scale
|
||||
private int retroWidth = 320;
|
||||
private int retroHeight = 180;
|
||||
@@ -31,9 +36,12 @@ namespace LunaLightXMG
|
||||
Content.RootDirectory = "Content";
|
||||
IsMouseVisible = true;
|
||||
|
||||
Window.ClientSizeChanged += OnClientSizeChanged; // Jensen can implement
|
||||
Window.ClientSizeChanged += OnClientSizeChanged;
|
||||
Window.AllowUserResizing = true;
|
||||
IsMouseVisible = true;
|
||||
|
||||
// Test player input and movement with abstracted player input class
|
||||
playerInput = new PlayerInput();
|
||||
}
|
||||
|
||||
private void OnClientSizeChanged(object sender, EventArgs eventArgs)
|
||||
@@ -53,6 +61,9 @@ namespace LunaLightXMG
|
||||
graphics.PreferredBackBufferHeight = 1080;
|
||||
graphics.ApplyChanges();
|
||||
|
||||
// Test player input and movement with abstracted player input class
|
||||
objectPosition = new Vector2(163, 63); // Initial position
|
||||
|
||||
base.Initialize();
|
||||
CalculateRenderDestination(); // Jensen can implement
|
||||
}
|
||||
@@ -89,7 +100,14 @@ namespace LunaLightXMG
|
||||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
|
||||
Exit();
|
||||
|
||||
// TODO: Add your update logic here
|
||||
playerInput.Update();
|
||||
|
||||
// Test player input and movement with abstracted player input class
|
||||
// Update the object's position based on input
|
||||
float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
objectPosition = playerInput.MoveWithWASD(objectPosition, movementSpeed * deltaTime);
|
||||
|
||||
|
||||
|
||||
base.Update(gameTime);
|
||||
}
|
||||
@@ -105,7 +123,10 @@ namespace LunaLightXMG
|
||||
spriteBatch.Begin(samplerState: SamplerState.PointClamp);
|
||||
// Draw sprites here
|
||||
spriteBatch.Draw(sprCave1_background,new Vector2(0,0),Color.White);
|
||||
spriteBatch.Draw(sprRo, new Vector2(163, 63), Color.White);
|
||||
|
||||
// Test player input and movement with abstracted player input class
|
||||
spriteBatch.Draw(sprRo, objectPosition, Color.White);
|
||||
|
||||
spriteBatch.Draw(sprCave1_walls, new Vector2(0, 0), Color.White);
|
||||
spriteBatch.Draw(sprCave1_foreground, new Vector2(0, 0), Color.White);
|
||||
spriteBatch.End();
|
||||
|
||||
Reference in New Issue
Block a user