From fff0c1fa65d32859149cc5036f51765c5455c046 Mon Sep 17 00:00:00 2001 From: "J. M. Ellis" Date: Fri, 14 Jun 2024 21:56:20 -0700 Subject: [PATCH] Minor update. --- Enemy.cs | 14 ++++++++++++-- Game1.cs | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Enemy.cs b/Enemy.cs index d990d5a..64e91e8 100644 --- a/Enemy.cs +++ b/Enemy.cs @@ -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)) diff --git a/Game1.cs b/Game1.cs index 5067ca3..3c93241 100644 --- a/Game1.cs +++ b/Game1.cs @@ -65,8 +65,8 @@ namespace LunaLightXMG random = new Random(42); // Init number of platforms / enemies - numOfPlatforms = 3; - numOfEnemies = 20; + numOfPlatforms = 4; + numOfEnemies = 10; } protected override void Initialize()