API Reference

Public API

class App : public Scriptable

Root of the engine and where the game loop is.

Public Functions

App(const stdf::path &app_path)

Construct an App using an AppConfig.

Parameters:

app_path – Path to the AppConfig to use

App(const App&) = delete

Note

Copying is not implemented

App(App&&) = default

Note

Explict move because of explicit copy delete

~App()

Note

Manually remove all attached Scripts

App &operator=(const App&) = delete

Note

Copying is not implemented

App &operator=(App&&) = default

Note

Explict move because of explicit copy delete

void run(seconds timeout = 0)

Run the game loop until the game ends.

Parameters:

timeout – Seconds until force ending the game loop and returning

virtual void foreachChild(Func<void(Scriptable&)> func) override

Iterate over every Stage as Scriptable.

Parameters:

func – Callback function called for every child Scriptable

virtual void foreachChild(Func<void(const Scriptable&)> func) const override

Iterate over every Stage as Scriptable.

Parameters:

func – Callback function called for every child Scriptable

class Stage : public Scriptable

Presents Scenes on a Window using layers.

Public Functions

Stage(const StageConfig &config, Scriptable *parent, AssetAPI &api)

Construct a Stage based on a Stage Config.

Parameters:
  • config – StageConfig the Stage is created from

  • parent – Parent Scriptable used for propagating events

  • asset_api – For usage by the client in EntityScripts

void update(float32 delta_time)

Update all Scenes of the Stage.

Parameters:

delta_time – Seconds elapsed since last update

void render()

Render the contents of all Scenes on the window (layered).

void foreachChild(Func<void(Scriptable&)> func)

Iterate over every Scene and the Window as Scriptable.

Parameters:

func – Callback function called for every child Scriptable

void foreachChild(Func<void(const Scriptable&)> func) const

Iterate over every Scene and the Window as Scriptable.

Parameters:

func – Callback function called for every child Scriptable

Public Members

Window window

The Window where the contents of the Scenes are presented.

List<Pair<Scene, Renderer>> scene_layers

Layered Scenes with their respective Renderer.

class Window : public Scriptable

Graphics Window for displaying the game.

Public Functions

Window(const WindowConfig &config, Scriptable *parent = nullptr)

Construct a Window based on a WindowConfig.

Parameters:
  • config – WindowConfig the Window is created from

  • parent – Parent Scriptable used for propagating events

Window(Window&&) = default

Note

Explict move because of explicit destructor

~Window()

Note

Manually remove all attached Scripts

Window &operator=(Window&&) = default

Note

Explict move because of explicit destructor

const string &getTitle()

Access the Window title.

Returns:

The title of the Window

void setIcon(const uchar *bytes, uint width, uint height)

Set the tray-icon of the Window.

Parameters:
  • bytes – The icon color buffer

  • width – The icon width

  • height – The icon height

bool isOpen() const

Is the Window still open.

Returns:

Whether the Window is open

void close()

Close the Window.

void setCursorState(CursorState state)
Parameters:

state

Vec2 getCursorCoords() const

Get the relative (to the top left of the Window) cursor position.

Returns:

The coordinates in pixels

void bind()

Bind the Window as a target for rendering commands.

void unbind()

Bind no Window as a target for rendering commands.

List<WindowEvent> pollEvents()

Poll all Events targeting the Window since last poll.

Returns:

A list of all WindowEvents in order

void swapBuffers()

Swap the Window and Display buffer for displaying.

virtual void foreachChild(Func<void(Scriptable&)> func) override

Do nothing.

Parameters:

func – Callback function called for every child Scriptable

virtual void foreachChild(Func<void(const Scriptable&)> func) const override

Do nothing.

Parameters:

func – Callback function called for every child Scriptable

class Scene : public Scriptable

Game world containing Entities in a hierarchy.

Public Functions

Scene(const SceneConfig &config, Scriptable *parent, AssetAPI &asset_api)

Construct a Scene based on a SceneConfig.

Parameters:
  • config – SceneConfig the Scene is created from

  • parent – Parent Scriptable used for propagating events

  • asset_api – For usage by the client in attached SceneScripts

Scene(Scene&&) = default

Note

Explict move because of explicit destructor

~Scene()

Note

Manually remove all attached Scripts

Scene &operator=(Scene&&) = default

Note

Explict move because of explicit destructor

void update(float32 delta_time)

Update all Entities, Components and Scripts in the Scene.

Parameters:

delta_time – Seconds elapsed since last update

template<class T>
List<Entity*> queryEntities()

Get all Entities in the Scene holding a certain Component type.

Template Parameters:

TComponent type

Returns:

Pointers to the Entities holding a Component of type T

template<class T>
List<const Entity*> queryEntities() const

Get all Entities in the Scene holding a certain Component type.

Template Parameters:

TComponent type

Returns:

Pointers to the Entities holding a Component of type T

virtual void foreachChild(Func<void(Scriptable&)> func) override

Iterate overy only one Scriptable, root.

Parameters:

func – Callback function called for with root

virtual void foreachChild(Func<void(const Scriptable&)> func) const override

Iterate overy only one Scriptable, root.

Parameters:

func – Callback function called for with root

Public Members

string name

Name of the Scene.

Entity root

Root Entity of the Scene where all Entities stem from.

Opt<RenderFunc> render = std::nullopt

Optionally specify the render pipeline for the Scene.

class Entity : public UUIDObject, public Scriptable

Hierarchical object composed by Components.

Public Functions

Entity(Scriptable *parent = nullptr)

Construct an Entity with no components or scripts attached.

Parameters:

parent – Parent Scriptable used for propagating events

Entity(SharedPtr<const EntityPreset> preset, Scriptable *parent, AssetAPI &asset_api)

Construct an Entity based on an EntityPreset.

Parameters:
  • preset – EntityPreset the Entity is based on

  • parent – Parent Scriptable used for propagating events

  • asset_api – For usage by the client in attached EntityScripts

Entity(const Entity&) = delete

Note

Copying attached Components is not implemented

Entity(Entity&&) = default

Note

Explict move because of explicit copy delete

~Entity()

Note

Manually remove all attached Scripts

Entity &operator=(const Entity&) = delete

Note

Copying attached Components is not implemented

Entity &operator=(Entity&&) = default

Note

Explict move because of explicit copy delete

const string &getTag() const

Access tag of the Entity.

Returns:

The tag of the Entity.

Set<Entity*> findByTag(strview tag, Set<Entity*> &&found = {})

Find all (recursive) children with a certain tag.

Parameters:
  • tag – The tag to be searched for

  • found – Children already found

Returns:

A Set with pointers to all found children

Set<const Entity*> findByTag(strview tag, Set<const Entity*> &&found = {}) const

Find all (recursive) children with a certain tag.

Parameters:
  • tag – The tag to be searched for

  • found – Children already found

Returns:

A Set with pointers to all found children

Entity &createChild(bool is_visible = false)

Create a child Entity.

Parameters:

is_visible – Whether the child Entity is visible, i.e. whether it can be accessed by non-immediate parents

Returns:

Reference to the created child Entity

bool destroyChild(UUID uuid)

Destroy child Entity with the UUID uuid.

Parameters:

uuid – The UUID of the child Entity

Returns:

Whether a child Entity with UUID uuid existed

bool destroyChild(strview tag)

Destroy child Entity with the tag tag.

Parameters:

tag – The tag of the child Entity

Returns:

Whether a child Entity with the tag tag existed

void foreachChild(Func<void(Entity&)> func)

Iterate over every child Entity.

Parameters:

func – Callback function called for every child Entity

void foreachChild(Func<void(const Entity&)> func) const

Iterate over every child Entity.

Parameters:

func – Callback function called for every child Entity

template<class T>
bool hasComponent() const
Template Parameters:

TComponent type

Returns:

Whether the Entity holds a Component of type T

template<class T>
T &getComponent()

Access existing Component of type T hold by the Entity.

Template Parameters:

TComponent type

Returns:

Reference to the Component of type T hold by the Entity

template<class T>
const T &getComponent() const

Access existing Component of type T hold by the Entity.

Template Parameters:

TComponent type

Returns:

Reference to the Component of type T hold by the Entity

template<class T, class ...Args>
T &addComponent(Args&&... args)

Emplace Component of type T.

Template Parameters:

TComponent type

Returns:

Reference to the constructed Component

template<class T>
void removeComponent()

Remove Component of type T from Entity.

Template Parameters:

TComponent type

void update(float32 delta_time)

Update all child Entities, Components and Scripts attached.

Parameters:

delta_time – Seconds elapsed since last update

virtual void foreachChild(Func<void(Scriptable&)> func) override

Iterate overy every child Entity as Scriptable.

Parameters:

func – Callback function called for every child Scriptable

virtual void foreachChild(Func<void(const Scriptable&)> func) const override

Iterate overy every child Entity as Scriptable.

Parameters:

func – Callback function called for every child Scriptable

Public Members

Transform transform

Position, rotation and scale of the Entity.

class Component

Reusable functionality to attach to Entities.

Subclassed by BasicComponent< T >

Public Functions

Component() = default

Note

Explicit default constructor because of default destructor

virtual ~Component() = default

Note

Virtual destructor for derived Components

virtual void update(float32 delta_time)

Component specific behaviour every time the game updates.

Parameters:

delta_time – Seconds elapsed since last update

virtual usize getID() const = 0

Uniquely identify Components using the derived Component type.

Returns:

Unique ID

Utilities

group Utilities

Common tools used for both game creation and parrot development.

class Stopwatch
#include <stopwatch.hh>

Measure time differences.

Internals (for Parrot Developers)

group Internals

Not intended for game creation use but only for parrot developers.

Typedefs

using AssetFactory = Func<SharedPtr<Asset>(const AssetPath&)>

Function that loads an Asset from the given location.

class Asset : public UUIDObject
#include <asset.hh>

Base class for game assets.

Subclassed by AppConfig, Camera, EntityPreset, Image, Light, Material, Model, RenderObject, SceneConfig, ShaderProgram, ShaderSource, StageConfig, TextureConfig, WindowConfig

class AssetAPI
#include <asset_handle.hh>

Interface for an Asset memory manager (loading and unloading).

Subclassed by AssetManager

template<class T, class ...Args>
class Factory
#include <factory.hh>

Interface for class that creates instances of T.

Template Parameters:
  • T – The type of the instances to be created

  • Args – The arguments passed to create to create an instance

template<class T, class ...Args>
class LambdaFactory : public Factory<T>
#include <factory.hh>

A basic implementation for Factory<Base> that calls a given method (usually a lambda) to create instances.

Template Parameters:
  • T – The type of the instances to be created

  • Args – The arguments passed to create to create an instance

template<class T, class Base>
class CopyFactory : public T, public Factory<Base>
#include <factory.hh>

A basic implementation for Factory<Base> that copies an existing instance to create instances.

Template Parameters:
  • T – The type of the instances to be created

  • Base – The base type to be returnend from the create method

class Script
#include <script.hh>

Base class for script types.

Subclassed by AppScript, EntityScript, SceneScript, StageScript