untested visualizer complete.

This commit is contained in:
2018-11-19 21:07:23 -06:00
parent 02d814b4f7
commit 57e76be95d
6 changed files with 143 additions and 21 deletions

View File

@@ -32,11 +32,14 @@ namespace RhythmBullet.Zer01HD.Utilities.Camera
Matrix.CreateTranslation(new Vector3(bounds.Width * 0.5f, bounds.Height * 0.5f, 0f));
}
public void LinearInterpolationToPosition(float alpha, Vector2 targetPosition)
public void LinearInterpolationToPosition(float alpha, Vector2 targetPosition, float delta)
{
if (alpha < 0 && alpha > 1f) throw new ArgumentException("Alpha can't be greater than 1f, or less than 0.");
Position.X = MathHelper.Lerp(Position.X, targetPosition.X, alpha);
Position.Y = MathHelper.Lerp(Position.Y, targetPosition.Y, alpha);
if (alpha <= 0 && alpha > 1f) throw new ArgumentException("Alpha can't be greater than 1f, less than or equal to 0.");
Vector2 distance = targetPosition - Position;
distance *= (float)(1.0f - Math.Pow(1 - alpha, delta / 0.02f));
Position += distance;
}
}
}

View File

@@ -45,7 +45,7 @@ namespace RhythmBullet.Zer01HD.UI.Book
Rectangle targetBounds = targetPage.Bounds;
position.X = targetBounds.X + (targetBounds.Width * 0.5f);
position.Y = targetBounds.Y + (targetBounds.Height * 0.5f);
camera.LinearInterpolationToPosition(0.4f, position);
camera.LinearInterpolationToPosition(0.4f, position, (float)gameTime.ElapsedGameTime.TotalSeconds);
if (camera.Position == position)
{
targetPage = null;