Skip to content

KernelAPI reference

Class GameLoop

Namespace: MicroEngine.Core
Assembly: MicroEngine.dll
Guide: Game lifecycle and time

The loop, one frame per Tick. It owns time: the platform only supplies a monotonic clock (Clock), and the engine’s FrameClock turns each frame’s time into fixed steps following the game’s TimeSettings (at most MaxStepsPerFrame a frame, frames of at most MaxFrameDelta). Each frame runs the engine’s frame schedule: the per-frame phases, the four fixed phases once per step, then the update, drawing and presentation phases. In deterministic time every frame is exactly one step, which makes scripted runs reproducible. Each frame starts with the platform’s event pump (PumpEvents), whose events become the engine’s lifecycle events (IEngineLifecycle) before the frame’s steps. Hosts that cannot block, such as a browser driving frames from requestAnimationFrame, call Tick themselves; errors are captured, never thrown.

C#
public sealed class GameLoop

Inheritance

object ← GameLoop

Constructors

GameLoop(Game, IPlatform, RunOptions?)

Prepares a loop; nothing runs until Start.

C#
public GameLoop(Game game, IPlatform platform, RunOptions? options = null)

Parameters

game Game

platform IPlatform

options RunOptions?

Exceptions

ArgumentNullException

game or platform is null.

GameLoop(Game, IPlatform, RunOptions?, Action<EngineBuilder>?)

Prepares a loop whose engine also gets the host’s composition: compose runs after the game’s Configure and before the run’s own systems (GameHost passes the content and engine changes of its HostBuilder this way).

C#
public GameLoop(Game game, IPlatform platform, RunOptions? options, Action<EngineBuilder>? compose)

Parameters

game Game

platform IPlatform

options RunOptions?

compose Action<EngineBuilder>?

Exceptions

ArgumentNullException

game or platform is null.

Properties

Frames

Frames rendered so far.

C#
public long Frames { get; }

Property Value

long

IsRunning

Whether the next Tick will run a frame.

C#
public bool IsRunning { get; }

Property Value

bool

Methods

Finish()

Shuts the game down (once) and reports the run.

C#
public RunResult Finish()

Returns

RunResult

Start()

Initializes the game; false when loading failed (the error is in Finish).

C#
public bool Start()

Returns

bool

Tick()

Runs one frame. Returns false once the game quit, the platform closed, a limit was hit or an error occurred.

C#
public bool Tick()

Returns

bool