Skip to content

Common-task quick reference

For game code after the starter is running: eight common tasks, with declarations read from this checkout’s published headers. This is a lookup page; the linked full contracts own preconditions, errors, lifetimes and platform limits.

Built from f525bc6. Match the documentation version to your engine pin; Which Labrador you have explains how.

Browse all modules and headers or follow a guide for a complete example. Member declarations below appear in their named class; they are not a standalone program. All public overloads of each selected name are shown.

Give the application its first state. The application owns the loop and the platform lifecycle.

// Application::run
int run(std::unique_ptr<State> first_state);
// Application::quit
void quit() const;

Contracts: Application::run (header) · Application::quit (header).

Guide and example: Read your starter’s C++.

Replace the current state, push a screen above it, or pop back. Read the contracts for deferral and result delivery.

// StateContext::transition_to
void transition_to(std::unique_ptr<State> state);
// StateContext::push
void push(std::unique_ptr<State> state);
void push(std::unique_ptr<State> state, std::function<void()> on_closed);
template <typename Result>
void push(std::unique_ptr<State> state,
std::function<void(const Result&)> on_result);
// StateContext::pop
void pop();
template <typename Result>
void pop(const Result& result);

Contracts: StateContext::transition_to (header) · StateContext::push (header) · StateContext::pop (header).

Guide and example: Add another screen.

Load named content from a manifest, then resolve the texture handle a drawable keeps.

// ResourceLoader::load_manifest
void load_manifest(AssetManifest manifest);
// RenderResources::resolve_texture
TextureHandle resolve_texture(const std::string& texture_name) const;

Contracts: ResourceLoader::load_manifest (header) · RenderResources::resolve_texture (header).

Guide and example: Assets.

Read the fixed update’s input snapshot. Key positions and UTF-8 typed characters are separate channels; bindings belong to the game.

// Keyboard::held
bool held(Key key) const;
// Keyboard::pressed
bool pressed(Key key) const;
// Keyboard::typed
std::string_view typed() const;

Contracts: Keyboard::held (header) · Keyboard::pressed (header) · Keyboard::typed (header).

Guide and example: Input.

Transfer ownership to the scene and commit pending changes at the tick boundary. Returned pointers borrow the object’s scene lifetime.

// Scene::add
template <typename T>
T* add(std::unique_ptr<T> object);
// Scene::remove
void remove(const GameObject* object);
// Scene::end_tick
void end_tick();

Contracts: Scene::add (header) · Scene::remove (header) · Scene::end_tick (header).

Guide and example: The game and its objects.

Record into the supplied view’s draw list. Draw stays const; order, coordinates, tint and handle lifetime follow the full contract.

// DrawList::set_camera
void set_camera(const Camera& camera);
// DrawList::draw_sprite
void draw_sprite(TextureHandle texture,
const RectangleI& source,
const RectangleF& destination,
const Colour& tint,
float rotation,
const Vector2F& origin,
SpriteFlip flip,
float layer_depth);

Contracts: DrawList::set_camera (header) · DrawList::draw_sprite (header).

Guide and example: Sprites and text.

Text stores wide characters and measures when the words change. Convert UTF-8 at the edit boundary and check the font’s coverage.

// Text::set_text
void set_text(const std::wstring& text) override;
// Text::set_position
void set_position(const Vector2F& position) override;

Contracts: Text::set_text (header) · Text::set_position (header).

Guide and example: Put words on screen.

Resolve a wave from the loaded bank, then play it. Browser activation, silent banks and suspended playback have explicit contracts.

// SoundBank::resolve_wave
WaveHandle resolve_wave(const std::string& wave_name) const;
// SoundBank::play_wave
void play_wave(WaveHandle wave, float volume = 1.0f,
float pitch = 0.0f, float pan = 0.0f) const;

Contracts: SoundBank::resolve_wave (header) · SoundBank::play_wave (header).

Guide and example: Audio.

Documentation for Labrador v0.4.0. Built from Labrador f525bc6 of 2026-11-17.

All documentation versions