Skip to content

Game Class

The MonoGame implementation of the SadConsole Game Host.

C#
public sealed class Game : GameHost, IDisposable

Inheritance objectGameHost

Implements IDisposable

When true, forces the OpenStream(string, FileMode, FileAccess) method to use

TitleContainer
when creating a stream to read a file.

C#
public bool UseTitleContainer { get; set; }

The Microsoft.Xna.Framework.Game instance.

C#
public Game MonoGameInstance { get; set; }

Strongly typed version of SadConsole.GameHost.Instance.

C#
public static Game Instance { get; set; }

Creates a new game with an 80x25 console that uses the default SadConsole IBM font.

C#
public static void Create()

Creates a new game with an initialization callback and a console set to the specific cell count that uses the default SadConsole IBM font.

C#
public static void Create(int cellCountX, int cellCountY)

cellCountX int
The width of the screen, in cells.

cellCountY int
The height of the screen, in cells.

Creates a new game with an initialization callback and a console set to the specific cell count that uses the specified font.

C#
public static void Create(int cellCountX, int cellCountY, EventHandler<GameHost> gameStarted)

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.

C#
public static void Create(int cellCountX, int cellCountY, string font, EventHandler<GameHost> gameStarted)

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.

Creates a new game and assigns it to the MonoGameInstance property.

C#
public static void Create(Builder configuration)

configuration Builder
The settings used in creating the game.

C#
public void Tick()

Runs the game.

C#
public override void Run()

Gets a texture from the implemented host.

C#
public override ITexture GetTexture(string resourcePath)

resourcePath string
The path to the texture to load.

ITexture
The texture from the game host.

Gets a texture from the implemented host.

C#
public override ITexture GetTexture(Stream textureStream)

textureStream Stream
A stream containing the texture.

ITexture
The texture from the game host.

Creates a texture.

C#
public override ITexture CreateTexture(int width, int height)

width int
The width of the texture in pixels.

height int
The height of the texture in pixels.

ITexture
The texture from the game host.

Gets the state of the keyboard from the implemented host.

C#
public override IKeyboardState GetKeyboardState()

IKeyboardState
The state of the keyboard.

Gets the state of the mouse from the implemented host.

C#
public override IMouseState GetMouseState()

IMouseState
The state of the mouse.

Gets the size of the current device’s screen in pixels.

C#
public override void GetDeviceScreenSize(out int width, out int height)

width int
The width of the screen.

height int
The height of the screen.

Opens a read-only stream with MonoGame.

C#
public override Stream OpenStream(string file, FileMode mode = FileMode.Open, FileAccess access = FileAccess.Read)

file string
The file to open.

mode FileMode
Unused by monogame.

access FileAccess
Unused by monogame.

Stream
The stream.

Toggles between windowed and full screen rendering for SadConsole.

C#
public void ToggleFullScreen()

Resizes the window to the specified dimensions.

C#
public override void ResizeWindow(int width, int height, bool resizeOutputSurface = false)

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