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 public class Enemy
{ {
private float hsp; // Horizontal speed private float hsp; // Horizontal speed
private float hspPrev;
private float vsp; // Vertical speed private float vsp; // Vertical speed
private float hsp_frac; // Horizontal fractional speed private float hsp_frac; // Horizontal fractional speed
private float vsp_frac; // Vertical fractional speed private float vsp_frac; // Vertical fractional speed
@@ -52,13 +53,20 @@ namespace LunaLightXMG
public void Draw(SpriteBatch spriteBatch) 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 ------------------------------------------------------------------------------- // Method Implementation -------------------------------------------------------------------------------
private void Movement() private void Movement()
{ {
if (hsp == 0) { hsp = 1; } if (hsp == 0) { hsp = hspPrev; }
if (walled) { hsp = -hsp; } if (walled) { hsp = -hsp; }
if (!grounded) { vsp += grv; } if (!grounded) { vsp += grv; }
if (RandomJump() && grounded) { vsp = vspJump; } if (RandomJump() && grounded) { vsp = vspJump; }
@@ -66,6 +74,8 @@ namespace LunaLightXMG
private void CollisionChecks(Platform[] platforms, Player player) private void CollisionChecks(Platform[] platforms, Player player)
{ {
// Remember hsp
hspPrev = hsp;
// Horizontal collision prediction // Horizontal collision prediction
float onePixh = Math.Sign(hsp); float onePixh = Math.Sign(hsp);
if (collisionManager.IsColliding(position + new Vector2(hsp, 0), boundingBox, platforms)) if (collisionManager.IsColliding(position + new Vector2(hsp, 0), boundingBox, platforms))
+2 -2
View File
@@ -65,8 +65,8 @@ namespace LunaLightXMG
random = new Random(42); random = new Random(42);
// Init number of platforms / enemies // Init number of platforms / enemies
numOfPlatforms = 3; numOfPlatforms = 4;
numOfEnemies = 20; numOfEnemies = 10;
} }
protected override void Initialize() protected override void Initialize()