From ff2246f74a2cb40c9f9c9a250978ed4133093e53 Mon Sep 17 00:00:00 2001 From: dnesov Date: Sun, 21 Jan 2024 18:16:42 +0100 Subject: [PATCH] Add Vector2 extensions. --- .../Source/Extensions/Vector2Extensions.cs | 12 ++++++++++++ TestGame/TestPlayer.cs | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 DaggerFramework/Source/Extensions/Vector2Extensions.cs diff --git a/DaggerFramework/Source/Extensions/Vector2Extensions.cs b/DaggerFramework/Source/Extensions/Vector2Extensions.cs new file mode 100644 index 0000000..c6f6d94 --- /dev/null +++ b/DaggerFramework/Source/Extensions/Vector2Extensions.cs @@ -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)); + } + } +} \ No newline at end of file diff --git a/TestGame/TestPlayer.cs b/TestGame/TestPlayer.cs index 06aff2f..95bf585 100644 --- a/TestGame/TestPlayer.cs +++ b/TestGame/TestPlayer.cs @@ -1,4 +1,5 @@ using DaggerFramework; +using DaggerFramework.Extensions; using DaggerFramework.SceneGraph; using DaggerFramework.Utils; @@ -32,7 +33,7 @@ public class TestPlayer : RectangleShape2d if (_camera is not null) { - _camera.Position = MathUtils.LerpVector2(_camera.Position, Position, dt * 5f); + _camera.Position = _camera.Position.Lerp(Position, dt * 5f); } }