On this page
  1. On pages of their own
  2. From rmp/app.h
  3. rmp::global<T>() — the state that outlives a scene change
    1. global
  4. From rmp/assets.h
  5. A sprite sheet, read straight out of an Aseprite file
    1. SheetFrame
    2. SheetTag
    3. SheetSlice
    4. SpriteSheet
    5. Texture, Image, Font, Sound, Music, Shader, RenderTexture
  6. From rmp/behavior.h
    1. PathOptions
    2. find_path
  7. From rmp/dialogue.h
    1. DialogueMarkup
    2. DialogueLine
    3. DialogueOption
    4. DialogueSaliency
  8. From rmp/object.h
  9. Shapes
    1. ShapeKind
    2. Shape
    3. rect, circle
  10. The edge of the world
    1. Edge
  11. What spawn() takes. The order is the order it gets written in
    1. ObjectOptions
    2. RayQuery
    3. RayHit
  12. From rmp/text.h
    1. TextOptions

rmp

namespace #include <rmp/app.h> #include <rmp/assets.h> #include <rmp/behavior.h> #include <rmp/dialogue.h> #include <rmp/object.h> #include <rmp/save.h> #include <rmp/scene.h> #include <rmp/text.h> #include <rmp/tilemap.h> #include <rmp/ui.h>

On pages of their own

  • rmp::SheetData — Everything read out of an .aseprite: the packed texture, the frames and the tags.
  • rmp::DialogueValue — A value of the Yarn language: a number, a string or a bool.
  • rmp::Dialogue — A conversation: a compiled Yarn script, where it is in it, and what it remembers.
  • rmp::Sprite — What an Object draws in place of its shape when it has one: a texture or a sheet, placed by origin around the object's position and turned, scaled and flipped with the object.
  • rmp::Callback — A function the framework keeps and calls later with arguments of types A...: what on_click(), on_drag(), on_collision() and Tilemap::on_object() store, and the type of the on_ fields of the behaviors.
  • rmp::Condition — A question the framework asks later with arguments of types A...: a StateMachine's transition, an Animator's rule, whether a Draggable may be dropped.
  • rmp::Ref — An optional reference: something that may not be there, and is not yours.
  • rmp::Handle — A reference to an object that is safe to keep across frames.
  • rmp::Object — An entity in a scene: the player, an enemy, a bullet, a coin, a platform.
  • rmp::Value — A tree: nothing, a bool, a number, a string, a list or an object — exactly what JSON holds, so a real structure fits and not only flat pairs.
  • rmp::Camera — The camera
  • rmp::Scene — A screen of the game — a main menu, a level, a pause overlay — with its own objects, map and camera.
  • rmp::TextArg — One placeholder's value: a name and a number or a text.
  • rmp::Text — A text the framework draws: translated when it was a literal, as it is when it was made at runtime.
  • rmp::MapObject — One object placed in the map, as spawn_objects() hands it to the factory registered for its type: where it is, how big, and its properties.
  • rmp::Tilemap — A level read from an LDtk or a Tiled file: its tile layers, which cells are solid, and the objects placed in it.
  • rmp::assets — rmp::Dialogue -- conversations written in Yarn Spinner 3.
  • rmp::save — rmp/save.h — rmp::Value, and saving the game.
  • rmp::lang — rmp::Text and rmp::lang -- the game in more than one language.

From rmp/app.h

rmp/app.h — the entry point, closing the app, and how the world fits the window.

rmp::global<T>() — the state that outlives a scene change

rmp::global<SaveData>().coins += 10;

One instance per type, built the first time it is asked for and destroyed by the framework on the way out, before the window closes. There is no registration, no name, no lookup: the TYPE is the key.

WHY IT IS CALLED global AND NOT SOMETHING SOFTER. Because that is what it is, and a name that hides it would get used for things that should have been passed as arguments. A scene owns its state and loses it when it leaves the stack — which is exactly right for the enemies and exactly wrong for the player's progress. This is for the second kind, and the blunt name is there so that reaching for it is a decision rather than a habit.

It is not a singleton in the pattern sense: T knows nothing about this, needs no instance() method, no private constructor and no macro. Any default- constructible type works, including a plain struct you wrote a minute ago.

THE ORDER IT IS DESTROYED IN is reverse of first use, and it happens while the window is still open — so a global holding an rmp::Texture releases it against a GL context that still exists. That is not free of charge to get right; see begin_stop() in src/rmp/app/app.cpp.

global

template <class T> T &global()

From rmp/assets.h

rmp::assets:: — loading from resources/

A sprite sheet, read straight out of an Aseprite file

SheetFrame

struct SheetFrame

One frame of a sheet: where it is in the packed texture, and how long it shows.

FieldTypeDefaultWhat it is
sourceRectangle{}

Where this frame is in the packed texture

secondsfloat0

From the file, so it plays at the speed you drew it

SheetTag

struct SheetTag

One tag of the .aseprite: a named run of frames, and the direction Aseprite plays it in. Its name is what sprite.play("walk") looks for.

FieldTypeDefaultWhat it is
namestd::string

The tag's name in Aseprite

fromint0

The first frame, an index into SheetData::frames

toint0

Inclusive, the way Aseprite counts

ping_pongboolfalse

Aseprite's "Ping-pong" direction: forwards, then back

reverseboolfalse

Aseprite's "Reverse" direction: last frame first

SheetSlice

struct SheetSlice

One slice of the .aseprite: a named rectangle the artist drew with the slice tool — an icon of an atlas, the frame of a button. With "9-Slices" ticked in Aseprite it also has a centre, which is what makes it a nine-slice (rmp::ui::nine_slice()). Read from the first frame the slice has a key on.

FieldTypeDefaultWhat it is
namestd::string

The slice's name in Aseprite

boundsRectangle{}

Where it is in the PACKED texture, in pixels

nineboolfalse

It has 9-slices: center is its middle

centerRectangle{}

The middle, relative to bounds; only when nine

SpriteSheet

using SpriteSheet = detail::Resource<SheetData, detail::ResourceKind::SHEET>

A loaded sprite sheet, from rmp::assets::load_sheet(). It shares and releases like the handles below, and raw() is its SheetData.

Texture, Image, Font, Sound, Music, Shader, RenderTexture

using Texture = detail::Resource<Texture2D, detail::ResourceKind::TEXTURE>
using Image = detail::Resource<::Image, detail::ResourceKind::IMAGE>
using Font = detail::Resource<::Font, detail::ResourceKind::FONT>
using Sound = detail::Resource<::Sound, detail::ResourceKind::SOUND>
using Music = detail::Resource<::Music, detail::ResourceKind::MUSIC>
using Shader = detail::Resource<::Shader, detail::ResourceKind::SHADER>
using RenderTexture = detail::Resource<RenderTexture2D, detail::ResourceKind::RENDER_TEXTURE>

The resource handles: each one is a detail::Resource around the raylib struct it is named after (Texture2D and RenderTexture2D for the two textures), and converts to it wherever raylib takes one. rmp::Texture, rmp::Image, rmp::Font and rmp::Sound come from the loaders in rmp::assets below. Nothing in rmp::assets returns an rmp::Music, rmp::Shader or rmp::RenderTexture; music is played by name through rmp::audio instead.

From rmp/behavior.h

rmp/behavior.h — the catalogue.

PathOptions

struct PathOptions

How rmp::find_path() looks for a way through a map.

FieldTypeDefaultWhat it is
diagonalbooltrue

Eight directions; false = four. A corner is never cut

clearancefloat0

Keeps this many units from every solid cell: half the walker's width

find_path

std::vector<Vector2> find_path(const Tilemap &map, Vector2 from, Vector2 to, const PathOptions &options = {})

The way from from to to across the map's cells, around its solid ones: the centres of the cells to walk through, ending on to itself. A* on the grid, with diagonal steps that never cut the corner of a solid cell. Empty when there is no way, when either end is outside the map or solid, and for a map with no cells. from itself is not on it.

From rmp/dialogue.h

rmp::Dialogue — conversations written in Yarn Spinner 3.

DialogueMarkup

struct DialogueMarkup

A piece of a line's markup: [wave]these words[/wave] is "wave" at the place of the first word, for as many characters (code points) as they have. Positions are in the line's text.

FieldTypeDefaultWhat it is
namestd::string

"wave", "color", "speed"...: what is in the brackets first

positionint0

The first character it covers, in code points of text

lengthint0

How many it covers; 0 for a self-closing [pause=0.4/]

propertiesstd::vector<std::pair<std::string, std::string>>

Name = value, as written

std::string property(std::string_view key) const

A property's value, or "" when the markup has none of that name.

DialogueLine

struct DialogueLine

A line of the conversation, ready to show.

FieldTypeDefaultWhat it is
idstd::string

Its #line: id, the key of its translation

speakerstd::string

Who says it ("Mika: ..."), or empty

textstd::string

What is said, in the current language, without the speaker or markup

markupstd::vector<DialogueMarkup>

Where the markup was, in text

tagsstd::vector<std::string>

Its #hashtags, without the #

DialogueOption

struct DialogueOption

One of the choices the player has now.

FieldTypeDefaultWhat it is
idstd::string

Its #line: id, the key of its translation

textstd::string

In the current language, without markup

availablebooltrue

False: its condition failed; shown disabled, or not at all

markupstd::vector<DialogueMarkup>

Where the markup was, in text

tagsstd::vector<std::string>

Its #hashtags, without the #

DialogueSaliency

enum class DialogueSaliency : std::uint8_t

How a line group (=>) or a node group (when:) picks among what can run.

ValueMeans
FIRSTThe first whose conditions pass
BESTThe one with the most conditions that pass
LEAST_SEENThe least seen, the most specific of those: the default
RANDOM_LEAST_SEENAs LEAST_SEEN, a random one among equals

From rmp/object.h

rmp/object.h — an entity inside a scene, and the handle that outlives it.

Shapes

ShapeKind

enum class ShapeKind

Which of the two a Shape is. RECTANGLE is a box of size and CIRCLE a disc of radius. NONE is no shape at all: nothing is drawn, and a collider of NONE means the object collides as its shape, or as its sprite's frame.

ValueMeans
NONE
RECTANGLE
CIRCLE

Shape

struct Shape

A rectangle or a circle around an object's centre, moved by offset and sized by the object's scale. An Object's shape is what it draws when it has no sprite and, unless its collider says otherwise, what it collides as. rect() and circle() make one.

FieldTypeDefaultWhat it is
kindShapeKindShapeKind::NONE

Declaration order IS the order these get written in a designated initialiser, because C++20 requires that and rejects any other order. Kind first because rect()/circle() set it, then the sizing, then the appearance.

sizeVector2{}

RECTANGLE: width and height

radiusfloat0

CIRCLE

offsetVector2{}

From the object's centre

colorColorWHITE

The fill, or the outline when not filled

filledbooltrue

False draws the outline only

thicknessfloat1

The outline's width when filled = false; a CIRCLE ignores it

rect, circle

Shape rect(Vector2 size)
Shape circle(float radius)

The two spellings that read like what they make.

The edge of the world

Edge

enum class Edge

What an object does at the edge of its bounds — the map's, or the view's, when bounds is empty. CLAMP and BOUNCE act as soon as world_bounds() crosses an edge; WRAP and DESTROY wait until it is entirely outside. Bounds that are not a finite box do nothing, said once.

ValueMeans
NONEThe default: objects may leave, and do
CLAMPStops at the edge a paddle, a player, a cursor
BOUNCEFlips the velocity a Pong or Breakout ball
WRAPComes back the other side Asteroids
DESTROYIs discarded once it has left bullets, particles (it has to have been inside)

What spawn() takes. The order is the order it gets written in

ObjectOptions

struct ObjectOptions

The starting values Scene::spawn() gives a new object. Each field sets the Object field of the same name, except size, which is a shorter way to write shape:

auto &wall = spawn({ .position = { 400, 225 }, .size = { 20, 200 } });
FieldTypeDefaultWhat it is
positionVector2{}

THE CENTRE, in world units

sizeVector2{}

Shorthand for a RECTANGLE shape of this size

shapeShape{}

The full form; used instead of size when set

velocityVector2{}

World units per second

scaleVector2{ 1, 1 }

Multiplies the shape, the collider and the sprite

rotationfloat0

Degrees, as raylib counts them

layerint0

Draw order: a higher layer draws on top

visiblebooltrue

False: not drawn, but still updated and collided

edgesEdgeEdge::NONE

What happens at the edge of bounds

boundsRectangle{}

{0,0,0,0} = the map's bounds, or the view without a map

RayQuery

struct RayQuery

What Scene::raycast() and Scene::raycast_all() test: the segment from from to to, against the scene's objects. The map's tiles are not hit; ask Tilemap::solid_at() about those. Down here, below Object, and not with the block about raycasting above, because ignore is a handle and a handle needs Object complete.

FieldTypeDefaultWhat it is
fromVector2{}

Where the ray starts, in world units

toVector2{}

Where it ends; nothing beyond it is hit

maskunsigned0xFFFFFFFFu

The same layers as the collision pass

ignoreHandle<Object>{}

Normally whoever is shooting: .ignore = self.handle(). Empty ignores nothing, and so does the handle of an object that is gone.

solid_onlyboolfalse

Only objects that are solid. A ground check wants the floor and not the coin lying on it, and a mask cannot say that: layers are about who collides with whom, and solid is about whether the contact resolves. Without this the nearest hit under a character is whatever trigger happens to be there, and the character walks through the floor.

Last in the struct, because added before the others it would shift a POSITIONAL initialiser — RayQuery{ a, b, mask, self.handle() } — onto the wrong fields. A designated one does not mind: it names its fields, in the order they are declared, and a new one in between is simply left out.

RayHit

struct RayHit

RayHit lives below Object too, for the same reason.

FieldTypeDefaultWhat it is
objectHandle<Object>

What was hit; a handle, so it is safe to keep across frames

pointVector2{}

Where, in world coordinates

normalVector2{}

The surface normal there, pointing back at the ray

distancefloat0

From the ray's origin

explicit operator bool() const

if (auto hit = raycast(a, b)) is the shape this is for.

From rmp/text.h

rmp::Text and rmp::lang — the game in more than one language.

TextOptions

struct TextOptions

What else a translated text can say: the context that tells two texts with the same words apart ("Open" a door, "Open" a file).

FieldTypeDefaultWhat it is
contextstd::string_view{}

The row's context column; empty: none