Add Vector2 extensions.
This commit is contained in:
12
DaggerFramework/Source/Extensions/Vector2Extensions.cs
Normal file
12
DaggerFramework/Source/Extensions/Vector2Extensions.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System.Numerics;
|
||||||
|
|
||||||
|
namespace DaggerFramework.Extensions
|
||||||
|
{
|
||||||
|
public static class Vector2Extensions
|
||||||
|
{
|
||||||
|
public static Vector2 Lerp(this Vector2 a, Vector2 b, double t)
|
||||||
|
{
|
||||||
|
return new Vector2(MathUtils.Lerp(a.X, b.X, t), MathUtils.Lerp(a.Y, b.Y, t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using DaggerFramework;
|
using DaggerFramework;
|
||||||
|
using DaggerFramework.Extensions;
|
||||||
using DaggerFramework.SceneGraph;
|
using DaggerFramework.SceneGraph;
|
||||||
using DaggerFramework.Utils;
|
using DaggerFramework.Utils;
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ public class TestPlayer : RectangleShape2d
|
|||||||
|
|
||||||
if (_camera is not null)
|
if (_camera is not null)
|
||||||
{
|
{
|
||||||
_camera.Position = MathUtils.LerpVector2(_camera.Position, Position, dt * 5f);
|
_camera.Position = _camera.Position.Lerp(Position, dt * 5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user