Dumped fractions.

This commit is contained in:
J. M. Ellis
2024-05-28 12:29:57 -07:00
parent 253a6ba80c
commit ef749d0666
+17 -1
View File
@@ -10,6 +10,8 @@ namespace LunaLightXMG
// Declare variables
private float hsp; // Horizontal speed
public float vsp; // Vertical speed
private float hsp_frac; // Hold fractional position data
private float vsp_frac; // Hold fractional position data
private float wallJumpDelay; // Delay for wall jumping
public bool grounded; // Is the player grounded?
public bool walled; // Is the player wall sliding?
@@ -35,6 +37,8 @@ namespace LunaLightXMG
// Initialize your variables here
hsp = 0;
vsp = 0;
hsp_frac = 0;
vsp_frac = 0;
wallJumpDelay = 0;
grounded = false;
walled = false;
@@ -62,7 +66,8 @@ namespace LunaLightXMG
{
// Update player position
Movement(input);
// Dump fractional position data.
DumpFractions();
// Update the player's bounding box
BoundingBox.Update(position, 8, 16);
@@ -126,6 +131,17 @@ namespace LunaLightXMG
return start;
}
private void DumpFractions()
{
// Movement Speeds
hsp += hsp_frac;
vsp += vsp_frac;
hsp_frac = hsp - (float)Math.Floor(hsp);
vsp_frac = vsp - (float)Math.Floor(vsp);
hsp -= hsp_frac;
vsp -= vsp_frac;
}
// Collision Checks - maybe abstract to a class ---------------------------------------------------------------
private void CollisionChecks(Platform[] platforms)
{