Show / Hide Table of Contents

Class Game

The MonoGame implementation of the SadConsole Game Host.

Inheritance
object
GameHost
Game
Implements
IDisposable
Inherited Members
GameHost.GetRenderer(string)
GameHost.SetRenderer(string, Type)
GameHost.SetRendererStep(string, Type)
GameHost.GetRendererStep(string)
GameHost.SetSplashScreens(params IScreenSurface[])
GameHost.LoadFont(string)
GameHost.DestroyDefaultStartingConsole()
GameHost.FileExists(string)
GameHost.FileDelete(string)
GameHost.ResizeWindow(int, int, Point, bool)
GameHost.SaveGlobalState()
GameHost.RestoreGlobalState()
GameHost.Dispose()
GameHost.SerializerPathHint
GameHost.DrawCalls
GameHost.ScreenCellsX
GameHost.ScreenCellsY
GameHost.FrameNumber
GameHost.Fonts
GameHost.EmbeddedFont
GameHost.EmbeddedFontExtended
GameHost.DefaultFont
GameHost.DefaultFontSize
GameHost.Keyboard
GameHost.Mouse
GameHost.UpdateFrameDelta
GameHost.DrawFrameDelta
GameHost.GameRunningTotalTime
GameHost.StartingConsole
GameHost.Screen
GameHost.RootComponents
GameHost.FocusedScreenObjects
GameHost.Random
GameHost.FrameRender
GameHost.FrameUpdate
GameHost.Started
GameHost.Ending
object.GetType()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: SadConsole
Assembly: SadConsole.Host.MonoGame.dll
Syntax
public sealed class Game : GameHost, IDisposable

Properties

Instance

Strongly typed version of Instance.

Declaration
public static Game Instance { get; set; }
Property Value
Type Description
Game

MonoGameInstance

The Microsoft.Xna.Framework.Game instance.

Declaration
public Game MonoGameInstance { get; set; }
Property Value
Type Description
Game

UseTitleContainer

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

TitleContainer
when creating a stream to read a file.
Declaration
public bool UseTitleContainer { get; set; }
Property Value
Type Description
bool

Methods

Create()

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

Declaration
public static void Create()

Create(Builder)

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

Declaration
public static void Create(Builder configuration)
Parameters
Type Name Description
Builder configuration

The settings used in creating the game.

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.

Declaration
public static void Create(int cellCountX, int cellCountY)
Parameters
Type Name Description
int cellCountX

The width of the screen, in cells.

int cellCountY

The height of the screen, in cells.

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.

Declaration
public static void Create(int cellCountX, int cellCountY, EventHandler<GameHost> gameStarted)
Parameters
Type Name Description
int cellCountX

The width of the screen, in cells.

int cellCountY

The height of the screen, in cells.

EventHandler<GameHost> gameStarted

An event handler to be invoked when the game starts.

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.

Declaration
public static void Create(int cellCountX, int cellCountY, string font, EventHandler<GameHost> gameStarted)
Parameters
Type Name Description
int cellCountX

The width of the screen, in cells.

int cellCountY

The height of the screen, in cells.

string font

The font file to load.

EventHandler<GameHost> gameStarted

An event handler to be invoked when the game starts.

CreateTexture(int, int)

Creates a texture.

Declaration
public override ITexture CreateTexture(int width, int height)
Parameters
Type Name Description
int width

The width of the texture in pixels.

int height

The height of the texture in pixels.

Returns
Type Description
ITexture

The texture from the game host.

Overrides
GameHost.CreateTexture(int, int)

GetDeviceScreenSize(out int, out int)

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

Declaration
public override void GetDeviceScreenSize(out int width, out int height)
Parameters
Type Name Description
int width

The width of the screen.

int height

The height of the screen.

Overrides
GameHost.GetDeviceScreenSize(out int, out int)

GetKeyboardState()

Gets the state of the keyboard from the implemented host.

Declaration
public override IKeyboardState GetKeyboardState()
Returns
Type Description
IKeyboardState

The state of the keyboard.

Overrides
GameHost.GetKeyboardState()

GetMouseState()

Gets the state of the mouse from the implemented host.

Declaration
public override IMouseState GetMouseState()
Returns
Type Description
IMouseState

The state of the mouse.

Overrides
GameHost.GetMouseState()

GetTexture(Stream)

Gets a texture from the implemented host.

Declaration
public override ITexture GetTexture(Stream textureStream)
Parameters
Type Name Description
Stream textureStream

A stream containing the texture.

Returns
Type Description
ITexture

The texture from the game host.

Overrides
GameHost.GetTexture(Stream)

GetTexture(string)

Gets a texture from the implemented host.

Declaration
public override ITexture GetTexture(string resourcePath)
Parameters
Type Name Description
string resourcePath

The path to the texture to load.

Returns
Type Description
ITexture

The texture from the game host.

Overrides
GameHost.GetTexture(string)

OpenStream(string, FileMode, FileAccess)

Opens a read-only stream with MonoGame.

Declaration
public override Stream OpenStream(string file, FileMode mode = FileMode.Open, FileAccess access = FileAccess.Read)
Parameters
Type Name Description
string file

The file to open.

FileMode mode

Unused by monogame.

FileAccess access

Unused by monogame.

Returns
Type Description
Stream

The stream.

Overrides
GameHost.OpenStream(string, FileMode, FileAccess)

ResizeWindow(int, int, bool)

Resizes the window to the specified dimensions.

Declaration
public override void ResizeWindow(int width, int height, bool resizeOutputSurface = false)
Parameters
Type Name Description
int width

The width of the window in pixels.

int height

The height of the window in pixels.

bool resizeOutputSurface

When true resizes the screen output surface along with the window. Defaults to false

Overrides
GameHost.ResizeWindow(int, int, bool)

Run()

Runs the game.

Declaration
public override void Run()
Overrides
GameHost.Run()

Tick()

Declaration
public void Tick()

ToggleFullScreen()

Toggles between windowed and full screen rendering for SadConsole.

Declaration
public void ToggleFullScreen()

Implements

IDisposable

Extension Methods

ExtensionsSystem.GetDebuggerDisplayValue(object)
In this article

Back to top

Back to top Generated by DocFX