diff options
Diffstat (limited to 'Djup.Native/Types.cs')
| -rw-r--r-- | Djup.Native/Types.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Djup.Native/Types.cs b/Djup.Native/Types.cs new file mode 100644 index 0000000..c930bd6 --- /dev/null +++ b/Djup.Native/Types.cs @@ -0,0 +1,41 @@ +using System.Runtime.InteropServices; + +namespace Djup.Native; + +[StructLayout(LayoutKind.Sequential)] +public struct Vec2 +{ + public float X { get; } + public float Y { get; } + + public Vec2(float x, float y) + { + X = x; + Y = y; + } + + public override string ToString() => $"({X}, {Y})"; +} + +public enum EntityKind +{ + None = 0, + Ball +} + +[StructLayout(LayoutKind.Explicit)] +public struct Entity +{ + [FieldOffset(0)] + public EntityKind kind; + + [FieldOffset(4)] + public Ball ball; +} + +[StructLayout(LayoutKind.Sequential)] +public struct Ball +{ + public Vec2 Position { get; set; } + public Vec2 Velocity { get; set; } +} |
