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()¶
Note
Manually remove all attached Scripts
-
void run(seconds timeout = 0)¶
Run the game loop until the game ends.
- Parameters:
timeout – Seconds until force ending the game loop and returning
-
App(const stdf::path &app_path)¶
-
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).
-
Stage(const StageConfig &config, Scriptable *parent, AssetAPI &api)¶
-
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()¶
Note
Manually remove all attached Scripts
-
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
-
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
-
List<WindowEvent> pollEvents()¶
Poll all Events targeting the Window since last poll.
- Returns:
A list of all WindowEvents in order
-
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
-
Window(const WindowConfig &config, Scriptable *parent = nullptr)¶
-
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()¶
Note
Manually remove all attached Scripts
-
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<class T>
List<const Entity*> queryEntities() const¶ Get all Entities in the Scene holding a certain Component type.
-
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
-
Scene(const SceneConfig &config, Scriptable *parent, AssetAPI &asset_api)¶
-
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
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()¶
Note
Manually remove all attached Scripts
-
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
-
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<class T>
void removeComponent()¶ Remove Component of type
Tfrom Entity.- Template Parameters:
T – Component type
-
void update(float32 delta_time)¶
Update all child Entities, Components and Scripts attached.
- Parameters:
delta_time – Seconds elapsed since last update
-
Entity(Scriptable *parent = nullptr)¶
-
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
-
Component() = default¶
Utilities¶
- group Utilities
Common tools used for both game creation and parrot development.
-
class Stopwatch¶
- #include <stopwatch.hh>
Measure time differences.
-
class Stopwatch¶
Internals (for Parrot Developers)¶
- group Internals
Not intended for game creation use but only for parrot developers.
Typedefs
-
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
createto 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
createto 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
createmethod
-
class Script¶
- #include <script.hh>
Base class for script types.
Subclassed by AppScript, EntityScript, SceneScript, StageScript
-
class Asset : public UUIDObject¶