Table of Contents

Class Game

Namespace
Axolotl2D
Assembly
Axolotl2D.dll

Represents the base game class for Axolotl2D.

public abstract class Game : IDisposable
Inheritance
Game
Implements
Inherited Members

Constructors

Game(IServiceProvider, int, int)

Construct a new game.

public Game(IServiceProvider serviceProvider, int maxDrawRate = 120, int maxUpdateRate = 120)

Parameters

serviceProvider IServiceProvider

Service provider to relay.

maxDrawRate int

Maximum frame rate.

maxUpdateRate int

Maximum update rate.

Properties

ClearColor

Represents the clear color of the game.

public Color ClearColor { get; set; }

Property Value

Color

CurrentFramerate

Represents the current framerate of the game.

public double CurrentFramerate { get; }

Property Value

double

LastDrawMilliseconds

Time spent producing the previous completed frame, in milliseconds.

public double LastDrawMilliseconds { get; }

Property Value

double

LastUpdateMilliseconds

Time spent in update callbacks during the previous update, in milliseconds.

public double LastUpdateMilliseconds { get; }

Property Value

double

Title

The window title.

public string Title { get; set; }

Property Value

string

Viewport

The current Viewport of the game.

public Vector2 Viewport { get; set; }

Property Value

Vector2

Methods

Cleanup()

Event that gets called when the game attempts to clean up.

protected abstract void Cleanup()

Dispose()

Disposes the game.

public void Dispose()

GetKeyboard()

Gets the keyboard input helper.

public IKeyboard? GetKeyboard()

Returns

IKeyboard

Keyboard input helper.

GetMouse()

Gets the mouse input helper.

public IMouse? GetMouse()

Returns

IMouse

Mouse input helper.

InitializeAsync(CancellationToken)

Loads application resources before the window and scene start.

protected virtual Task InitializeAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Stops startup resource loading.

Returns

Task

Events

OnDraw

Called when the game draws.

public event Game.DrawDelegate? OnDraw

Event Type

Game.DrawDelegate

OnLoad

Called after the window, renderer, and input initialize. Keep handlers synchronous; override InitializeAsync(CancellationToken) for awaited startup work.

public event Game.LoadDelegate? OnLoad

Event Type

Game.LoadDelegate

OnResize

Called when the game window resizes.

public event Game.ResizeDelegate? OnResize

Event Type

Game.ResizeDelegate

OnUpdate

Called when the game updates.

public event Game.UpdateDelegate? OnUpdate

Event Type

Game.UpdateDelegate