feat: EngineConverter.ApplyDisplayScale

This commit is contained in:
Syntriax 2024-01-25 12:12:53 +03:00
parent bf825fd961
commit faf30b8227
2 changed files with 3 additions and 3 deletions

View File

@ -10,9 +10,7 @@ namespace Pong.Behaviours;
public class ShapeAABBBehaviour : BehaviourOverride, IDisplayableShape public class ShapeAABBBehaviour : BehaviourOverride, IDisplayableShape
{ {
private Shape transformedShape = new([]);
private IShapeCollider2D? shapeCollider = null; private IShapeCollider2D? shapeCollider = null;
private readonly static Vector2D screenScale = Vector2D.Down + Vector2D.Right;
public ShapeAABBBehaviour() { } public ShapeAABBBehaviour() { }
public ShapeAABBBehaviour(float Thickness) { this.Thickness = Thickness; } public ShapeAABBBehaviour(float Thickness) { this.Thickness = Thickness; }
@ -36,6 +34,6 @@ public class ShapeAABBBehaviour : BehaviourOverride, IDisplayableShape
shapeBatch.BorderCircle(aabb.Center.ToDisplayVector2(), 7.5f, Color.Beige); shapeBatch.BorderCircle(aabb.Center.ToDisplayVector2(), 7.5f, Color.Beige);
shapeBatch.DrawRectangle(aabb.Center.Scale(screenScale).Subtract(aabb.SizeHalf).ToVector2(), aabb.Size.ToVector2(), Color.Transparent, Color.Blue); shapeBatch.DrawRectangle(aabb.Center.ApplyDisplayScale().Subtract(aabb.SizeHalf).ToVector2(), aabb.Size.ToVector2(), Color.Transparent, Color.Blue);
} }
} }

View File

@ -16,4 +16,6 @@ public static class EngineConverter
public static Vector2 ToVector2(this Vector2D vector) => new(vector.X, vector.Y); public static Vector2 ToVector2(this Vector2D vector) => new(vector.X, vector.Y);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector2 ToDisplayVector2(this Vector2D vector) => vector.Scale(screenScale).ToVector2(); public static Vector2 ToDisplayVector2(this Vector2D vector) => vector.Scale(screenScale).ToVector2();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector2D ApplyDisplayScale(this Vector2D vector) => vector.Scale(screenScale);
} }