Minor update.

This commit is contained in:
J. M. Ellis
2024-06-14 21:56:20 -07:00
parent f9045a49e8
commit fff0c1fa65
2 changed files with 14 additions and 4 deletions
+12 -2
View File
@@ -8,6 +8,7 @@ namespace LunaLightXMG
public class Enemy
{
private float hsp; // Horizontal speed
private float hspPrev;
private float vsp; // Vertical speed
private float hsp_frac; // Horizontal fractional speed
private float vsp_frac; // Vertical fractional speed
@@ -52,13 +53,20 @@ namespace LunaLightXMG
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(texture, position, Color.White);
if (hsp <= 1 && hsp >= -1)
{
spriteBatch.Draw(texture, position, Color.White);
}
else
{
spriteBatch.Draw(texture, position, Color.Red);
}
}
// Method Implementation -------------------------------------------------------------------------------
private void Movement()
{
if (hsp == 0) { hsp = 1; }
if (hsp == 0) { hsp = hspPrev; }
if (walled) { hsp = -hsp; }
if (!grounded) { vsp += grv; }
if (RandomJump() && grounded) { vsp = vspJump; }
@@ -66,6 +74,8 @@ namespace LunaLightXMG
private void CollisionChecks(Platform[] platforms, Player player)
{
// Remember hsp
hspPrev = hsp;
// Horizontal collision prediction
float onePixh = Math.Sign(hsp);
if (collisionManager.IsColliding(position + new Vector2(hsp, 0), boundingBox, platforms))