Can toggle game music now.

This commit is contained in:
jme9
2025-03-30 14:55:16 -07:00
parent 43903e6c42
commit 218f4da157
4 changed files with 18 additions and 20 deletions
+8 -11
View File
@@ -12,7 +12,7 @@ namespace LunaLightXMG
private float rotation;
private Vector2 position;
private Rectangle levelBounds;
private readonly float camSpeed = 0.1f;
private readonly float camSpeed = 5.0f;
// Screen Shake
private float shakeTimeRemaining = 0f;
@@ -64,16 +64,13 @@ namespace LunaLightXMG
levelBounds = bounds;
}
public void Follow(Vector2 targetPostion)
public void Follow(GameTime gameTime, Vector2 targetPostion)
{
position += (targetPostion - position) * camSpeed;
if (Math.Abs(position.X - targetPostion.X) < 0.1f)
float smoothSpeed = camSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
position = Vector2.Lerp(position, targetPostion, smoothSpeed);
if (Vector2.Distance(position, targetPostion) < 1.0f)
{
position.X = targetPostion.X;
}
if (Math.Abs(position.Y - targetPostion.Y) < 0.1f)
{
position.Y = targetPostion.Y;
position = targetPostion;
}
ClampToBounds();
}
@@ -91,8 +88,8 @@ namespace LunaLightXMG
if (shakeTimeRemaining > 0)
{
float shakeX = util.ChooseFromRange(-shakeMagnitudeCurrent, shakeMagnitudeCurrent);
float shakeY = util.ChooseFromRange(-shakeMagnitudeCurrent, shakeMagnitudeCurrent);
float shakeX = util.RandomFromRange(-shakeMagnitudeCurrent, shakeMagnitudeCurrent);
float shakeY = util.RandomFromRange(-shakeMagnitudeCurrent, shakeMagnitudeCurrent);
position.X += shakeX;
position.Y += shakeY;
shakeTimeRemaining -= (float)gameTime.ElapsedGameTime.TotalSeconds;