2024-01-23 12:16:58 +03:00
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
using Syntriax.Engine.Core;
|
|
|
|
|
|
|
|
namespace Pong;
|
|
|
|
|
2024-01-23 12:17:14 +03:00
|
|
|
public static class EngineConverter
|
2024-01-23 12:16:58 +03:00
|
|
|
{
|
2024-01-24 19:25:31 +03:00
|
|
|
public readonly static Vector2D screenScale = Vector2D.Down + Vector2D.Right;
|
|
|
|
|
2024-01-23 12:16:58 +03:00
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
public static EngineTime ToEngineTime(this GameTime gameTime) => new(gameTime.TotalGameTime, gameTime.ElapsedGameTime);
|
2024-01-23 12:15:24 +03:00
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
public static Vector2D ToVector2D(this Vector2 vector) => new(vector.X, vector.Y);
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-01-25 22:15:52 +03:00
|
|
|
public static Vector2D ToVector2D(this Point point) => new(point.X, point.Y);
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-01-23 12:15:24 +03:00
|
|
|
public static Vector2 ToVector2(this Vector2D vector) => new(vector.X, vector.Y);
|
2024-01-24 19:25:31 +03:00
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
public static Vector2 ToDisplayVector2(this Vector2D vector) => vector.Scale(screenScale).ToVector2();
|
2024-01-25 12:12:53 +03:00
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
public static Vector2D ApplyDisplayScale(this Vector2D vector) => vector.Scale(screenScale);
|
2024-01-23 12:16:58 +03:00
|
|
|
}
|