Game Class
Definition
Section titled “Definition”The MonoGame implementation of the SadConsole Game Host.
public sealed class Game : GameHost, IDisposableImplements IDisposable
Properties
Section titled “Properties”UseTitleContainer
Section titled “UseTitleContainer”When true, forces the OpenStream(string, FileMode, FileAccess) method to use
TitleContainer when creating a stream to read a file.
public bool UseTitleContainer { get; set; }MonoGameInstance
Section titled “MonoGameInstance”The Microsoft.Xna.Framework.Game instance.
public Game MonoGameInstance { get; set; }Instance
Section titled “Instance”Strongly typed version of SadConsole.GameHost.Instance.
public static Game Instance { get; set; }Methods
Section titled “Methods”Create()
Section titled “Create()”Creates a new game with an 80x25 console that uses the default SadConsole IBM font.
public static void Create()Create(int, int)
Section titled “Create(int, int)”Creates a new game with an initialization callback and a console set to the specific cell count that uses the default SadConsole IBM font.
public static void Create(int cellCountX, int cellCountY)Parameters
Section titled “Parameters”cellCountX int
The width of the screen, in cells.
cellCountY int
The height of the screen, in cells.
Create(int, int, EventHandler<GameHost>)
Section titled “Create(int, int, EventHandler<GameHost>)”Creates a new game with an initialization callback and a console set to the specific cell count that uses the specified font.
public static void Create(int cellCountX, int cellCountY, EventHandler<GameHost> gameStarted)Parameters
Section titled “Parameters”cellCountX int
The width of the screen, in cells.
cellCountY int
The height of the screen, in cells.
gameStarted EventHandler<GameHost>
An event handler to be invoked when the game starts.
Create(int, int, string, EventHandler<GameHost>)
Section titled “Create(int, int, string, EventHandler<GameHost>)”Creates a new game with the specific screen size, and an initialization callback. Loads the specified font as the default.
public static void Create(int cellCountX, int cellCountY, string font, EventHandler<GameHost> gameStarted)Parameters
Section titled “Parameters”cellCountX int
The width of the screen, in cells.
cellCountY int
The height of the screen, in cells.
font string
The font file to load.
gameStarted EventHandler<GameHost>
An event handler to be invoked when the game starts.
Create(Builder)
Section titled “Create(Builder)”Creates a new game and assigns it to the MonoGameInstance property.
public static void Create(Builder configuration)Parameters
Section titled “Parameters”configuration Builder
The settings used in creating the game.
Tick()
Section titled “Tick()”public void Tick()Runs the game.
public override void Run()GetTexture(string)
Section titled “GetTexture(string)”Gets a texture from the implemented host.
public override ITexture GetTexture(string resourcePath)Parameters
Section titled “Parameters”resourcePath string
The path to the texture to load.
Returns
Section titled “Returns”ITexture
The texture from the game host.
GetTexture(Stream)
Section titled “GetTexture(Stream)”Gets a texture from the implemented host.
public override ITexture GetTexture(Stream textureStream)Parameters
Section titled “Parameters”textureStream Stream
A stream containing the texture.
Returns
Section titled “Returns”ITexture
The texture from the game host.
CreateTexture(int, int)
Section titled “CreateTexture(int, int)”Creates a texture.
public override ITexture CreateTexture(int width, int height)Parameters
Section titled “Parameters”width int
The width of the texture in pixels.
height int
The height of the texture in pixels.
Returns
Section titled “Returns”ITexture
The texture from the game host.
GetKeyboardState()
Section titled “GetKeyboardState()”Gets the state of the keyboard from the implemented host.
public override IKeyboardState GetKeyboardState()Returns
Section titled “Returns”IKeyboardState
The state of the keyboard.
GetMouseState()
Section titled “GetMouseState()”Gets the state of the mouse from the implemented host.
public override IMouseState GetMouseState()Returns
Section titled “Returns”IMouseState
The state of the mouse.
GetDeviceScreenSize(out int, out int)
Section titled “GetDeviceScreenSize(out int, out int)”Gets the size of the current device’s screen in pixels.
public override void GetDeviceScreenSize(out int width, out int height)Parameters
Section titled “Parameters”width int
The width of the screen.
height int
The height of the screen.
OpenStream(string, FileMode, FileAccess)
Section titled “OpenStream(string, FileMode, FileAccess)”Opens a read-only stream with MonoGame.
public override Stream OpenStream(string file, FileMode mode = FileMode.Open, FileAccess access = FileAccess.Read)Parameters
Section titled “Parameters”file string
The file to open.
mode FileMode
Unused by monogame.
access FileAccess
Unused by monogame.
Returns
Section titled “Returns”Stream
The stream.
ToggleFullScreen()
Section titled “ToggleFullScreen()”Toggles between windowed and full screen rendering for SadConsole.
public void ToggleFullScreen()ResizeWindow(int, int, bool)
Section titled “ResizeWindow(int, int, bool)”Resizes the window to the specified dimensions.
public override void ResizeWindow(int width, int height, bool resizeOutputSurface = false)Parameters
Section titled “Parameters”width int
The width of the window in pixels.
height int
The height of the window in pixels.
resizeOutputSurface bool
When true resizes the screen output surface along with the window. Defaults to false