documentation.

This commit is contained in:
2019-01-14 00:34:35 -06:00
parent 32c2f25196
commit 40c7772559
15 changed files with 315 additions and 56 deletions

View File

@@ -4,13 +4,32 @@ using System;
namespace RecrownedAthenaeum.Camera
{
/// <summary>
/// A virtual 2D camera.
/// </summary>
public class Camera2D
{
/// <summary>
/// Current zoom level.
/// </summary>
public float Zoom;
public Vector2 Position;
public Matrix Matrix { get; private set; }
public GraphicsDevice graphicsDevice;
/// <summary>
/// Current position in the world.
/// </summary>
public Vector2 Position;
/// <summary>
/// The matrix representing the zoom and position.
/// </summary>
public Matrix Matrix { get; private set; }
private GraphicsDevice graphicsDevice;
/// <summary>
/// Constructs 2D camera.
/// </summary>
/// <param name="graphicsDevice">The graphics device to use.</param>
public Camera2D(GraphicsDevice graphicsDevice)
{
this.graphicsDevice = graphicsDevice;
@@ -19,6 +38,9 @@ namespace RecrownedAthenaeum.Camera
Position.Y = this.graphicsDevice.Viewport.Height * 0.5f;
}
/// <summary>
/// Applies any changes made to the properties of this camera and updates to new dimensions of viewport specified by the graphics device.
/// </summary>
public void Update()
{
Rectangle bounds = graphicsDevice.Viewport.Bounds;
@@ -28,6 +50,12 @@ namespace RecrownedAthenaeum.Camera
Matrix.CreateTranslation(new Vector3(bounds.Width * 0.5f, bounds.Height * 0.5f, 0f));
}
/// <summary>
/// Lerps to the given position.
/// </summary>
/// <param name="alpha">The multiplier for difference in distance.</param>
/// <param name="targetPosition">The target position to lerp to.</param>
/// <param name="delta">Time between this frame and the previous frame.</param>
public void LinearInterpolationToPosition(float alpha, Vector2 targetPosition, float delta)
{
if (alpha <= 0 && alpha > 1f) throw new ArgumentException("Alpha can't be greater than 1f, less than or equal to 0.");