mirror of
https://github.com/TheRavenwoodArts/LunaLightXMG.git
synced 2026-07-30 22:05:02 -07:00
Renamed all snake_case variables to use camelCase.
This commit is contained in:
@@ -17,9 +17,9 @@ namespace LunaLightXMG
|
||||
|
||||
// Test sprites
|
||||
Texture2D sprRo;
|
||||
Texture2D sprCave1_background;
|
||||
Texture2D sprCave1_foreground;
|
||||
Texture2D sprCave1_walls;
|
||||
Texture2D sprCave1Background;
|
||||
Texture2D sprCave1Foreground;
|
||||
Texture2D sprCave1Walls;
|
||||
|
||||
// Test player input and movement with abstracted player class
|
||||
private Player player;
|
||||
@@ -36,7 +36,7 @@ namespace LunaLightXMG
|
||||
|
||||
Window.ClientSizeChanged += OnClientSizeChanged;
|
||||
Window.AllowUserResizing = true;
|
||||
IsMouseVisible = true;
|
||||
IsMouseVisible = true;
|
||||
|
||||
// Test player input and movement with abstracted player class
|
||||
player = new Player();
|
||||
@@ -81,9 +81,9 @@ namespace LunaLightXMG
|
||||
{
|
||||
spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
sprRo = Content.Load<Texture2D>("sprRo_Wall");
|
||||
sprCave1_background = Content.Load<Texture2D>("spr_cave1_background");
|
||||
sprCave1_foreground = Content.Load<Texture2D>("spr_Cave1_foreground");
|
||||
sprCave1_walls = Content.Load<Texture2D>("spr_Cave1_walls");
|
||||
sprCave1Background = Content.Load<Texture2D>("spr_cave1_background");
|
||||
sprCave1Foreground = Content.Load<Texture2D>("spr_Cave1_foreground");
|
||||
sprCave1Walls = Content.Load<Texture2D>("spr_Cave1_walls");
|
||||
|
||||
// Test Render Target
|
||||
renderTarget = new RenderTarget2D(GraphicsDevice, retroWidth, retroHeight);
|
||||
@@ -111,13 +111,13 @@ namespace LunaLightXMG
|
||||
// Test Sprite
|
||||
spriteBatch.Begin(samplerState: SamplerState.PointClamp);
|
||||
// Draw sprites here
|
||||
spriteBatch.Draw(sprCave1_background,new Vector2(0,0),Color.White);
|
||||
spriteBatch.Draw(sprCave1Background,new Vector2(0,0),Color.White);
|
||||
|
||||
// Test player input and movement with abstracted player class
|
||||
player.Draw(spriteBatch, sprRo);
|
||||
|
||||
spriteBatch.Draw(sprCave1_walls, new Vector2(0, 0), Color.White);
|
||||
spriteBatch.Draw(sprCave1_foreground, new Vector2(0, 0), Color.White);
|
||||
spriteBatch.Draw(sprCave1Walls, new Vector2(0, 0), Color.White);
|
||||
spriteBatch.Draw(sprCave1Foreground, new Vector2(0, 0), Color.White);
|
||||
spriteBatch.End();
|
||||
|
||||
|
||||
|
||||
@@ -13,22 +13,22 @@ namespace LunaLightXMG
|
||||
private float wallJumpDelay; // Delay for wall jumping
|
||||
private bool grounded; // Is the player grounded?
|
||||
private bool walled; // Is the player wall sliding?
|
||||
private float hsp_acc; // Horizontal acceleration
|
||||
private float hsp_friction_ground; // Ground friction
|
||||
private float hsp_friction_air; // Air friction
|
||||
private float hsp_walk; // Maximum horizontal speed
|
||||
private float hspAcc; // Horizontal acceleration
|
||||
private float hspFrictionGround; // Ground friction
|
||||
private float hspFrictionAir; // Air friction
|
||||
private float hspWalk; // Maximum horizontal speed
|
||||
private float grv; // Gravity
|
||||
private float vsp_max; // Maximum vertical speed
|
||||
private float grv_wall; // Gravity when wall sliding
|
||||
private float vsp_max_wall; // Maximum vertical speed when wall sliding
|
||||
private float vsp_jump; // Jump speed
|
||||
private float vspMax; // Maximum vertical speed
|
||||
private float grvWall; // Gravity when wall sliding
|
||||
private float vspMaxWall; // Maximum vertical speed when wall sliding
|
||||
private float vspJump; // Jump speed
|
||||
|
||||
// Player position
|
||||
public Vector2 Position;
|
||||
|
||||
// Placeholder for key input states
|
||||
private bool key_left;
|
||||
private bool key_right;
|
||||
private bool keyLeft;
|
||||
private bool keyRight;
|
||||
|
||||
// Constructor to initialize variables
|
||||
public Player()
|
||||
@@ -39,16 +39,16 @@ namespace LunaLightXMG
|
||||
wallJumpDelay = 0;
|
||||
grounded = false;
|
||||
walled = false;
|
||||
hsp_acc = 0.5f;
|
||||
hsp_friction_ground = 0.2f;
|
||||
hsp_friction_air = 0.1f;
|
||||
hsp_walk = 4f;
|
||||
hspAcc = 0.5f;
|
||||
hspFrictionGround = 0.2f;
|
||||
hspFrictionAir = 0.1f;
|
||||
hspWalk = 4f;
|
||||
//grv = 0.5f;
|
||||
grv = 0.0f; // No grav until we have walls, bounding boxes, etc..
|
||||
vsp_max = 10f;
|
||||
grv_wall = 0.1f;
|
||||
vsp_max_wall = 5f;
|
||||
vsp_jump = -10f;
|
||||
vspMax = 10f;
|
||||
grvWall = 0.1f;
|
||||
vspMaxWall = 5f;
|
||||
vspJump = -10f;
|
||||
|
||||
Position = new Vector2(163, 63); // Initialize player position
|
||||
}
|
||||
@@ -71,30 +71,30 @@ namespace LunaLightXMG
|
||||
|
||||
if (wallJumpDelay == 0) // no left-right control until delay is 0, prevents rapid wall climb
|
||||
{
|
||||
float move_h = (key_right ? 1 : 0) - (key_left ? 1 : 0);
|
||||
hsp += move_h * hsp_acc;
|
||||
float moveH = (keyRight ? 1 : 0) - (keyLeft ? 1 : 0);
|
||||
hsp += moveH * hspAcc;
|
||||
|
||||
if (move_h == 0)
|
||||
if (moveH == 0)
|
||||
{
|
||||
float hsp_friction_final = grounded ? hsp_friction_ground : hsp_friction_air;
|
||||
hsp = Approach(hsp, 0, hsp_friction_final);
|
||||
float hspFrictionFinal = grounded ? hspFrictionGround : hspFrictionAir;
|
||||
hsp = Approach(hsp, 0, hspFrictionFinal);
|
||||
}
|
||||
|
||||
hsp = MathHelper.Clamp(hsp, -hsp_walk, hsp_walk);
|
||||
hsp = MathHelper.Clamp(hsp, -hspWalk, hspWalk);
|
||||
}
|
||||
|
||||
// Calculate vertical movement
|
||||
float grv_final = grv;
|
||||
float vsp_max_final = vsp_max;
|
||||
float grvFinal = grv;
|
||||
float vspMaxFinal = vspMax;
|
||||
|
||||
if (walled && vsp > 0)
|
||||
{
|
||||
grv_final = grv_wall;
|
||||
vsp_max_final = vsp_max_wall;
|
||||
grvFinal = grvWall;
|
||||
vspMaxFinal = vspMaxWall;
|
||||
}
|
||||
|
||||
vsp += (vsp == 0 ? grv_final * 2 : grv_final);
|
||||
vsp = MathHelper.Clamp(vsp, vsp_jump, vsp_max_final);
|
||||
vsp += (vsp == 0 ? grvFinal * 2 : grvFinal);
|
||||
vsp = MathHelper.Clamp(vsp, vspJump, vspMaxFinal);
|
||||
}
|
||||
|
||||
// Helper method to smoothly approach a target value
|
||||
@@ -119,8 +119,8 @@ namespace LunaLightXMG
|
||||
private void HandleInput()
|
||||
{
|
||||
KeyboardState keyboardState = Keyboard.GetState();
|
||||
key_left = keyboardState.IsKeyDown(Keys.A);
|
||||
key_right = keyboardState.IsKeyDown(Keys.D);
|
||||
keyLeft = keyboardState.IsKeyDown(Keys.A);
|
||||
keyRight = keyboardState.IsKeyDown(Keys.D);
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, Texture2D texture)
|
||||
|
||||
Reference in New Issue
Block a user