diff options
Diffstat (limited to 'MonoGameLibrary/Core.cs')
| -rw-r--r-- | MonoGameLibrary/Core.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/MonoGameLibrary/Core.cs b/MonoGameLibrary/Core.cs new file mode 100644 index 0000000..9e4c9e3 --- /dev/null +++ b/MonoGameLibrary/Core.cs @@ -0,0 +1,48 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; + +namespace MonoGameLibrary; + +public class Core : Game { + internal static Core s_instance; + + public static Core Instance => s_instance; + + public static GraphicsDeviceManager Graphics { get; set; } + public static new GraphicsDevice GraphicsDevice { get; private set; } + public static SpriteBatch SpriteBatch { get; private set; } + public static new ContentManager Content { get; private set; } + + public Core(string title, int width, int height, bool fullscreen) { + if (s_instance != null) { + throw new InvalidOperationException($"Only a single Core instance can be created"); + } + + s_instance = this; + + Graphics = new GraphicsDeviceManager(this); + + Graphics.PreferredBackBufferWidth = width; + Graphics.PreferredBackBufferHeight = height; + Graphics.IsFullScreen = fullscreen; + + Graphics.ApplyChanges(); + + Window.Title = title; + + Content = base.Content; + + Content.RootDirectory = "Content"; + + IsMouseVisible = true; + } + + protected override void Initialize() { + base.Initialize(); + + GraphicsDevice = base.GraphicsDevice; + SpriteBatch = new SpriteBatch(GraphicsDevice); + } +} |
