mirror of
https://github.com/TheRavenwoodArts/LunaLightXMG.git
synced 2026-07-30 23:35:02 -07:00
Minor update.
This commit is contained in:
@@ -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))
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user