Engine-Pong/Game/EngineConverter.cs

22 lines
1015 B
C#
Raw Normal View History

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
{
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)]
public static Vector2 ToVector2(this Vector2D vector) => new(vector.X, vector.Y);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector2 ToDisplayVector2(this Vector2D vector) => vector.Scale(screenScale).ToVector2();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector2D ApplyDisplayScale(this Vector2D vector) => vector.Scale(screenScale);
2024-01-23 12:16:58 +03:00
}