rmp
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 byoriginaround 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...: whaton_click(),on_drag(),on_collision()andTilemap::on_object()store, and the type of theon_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 camerarmp::Scene— A screen of the game — a main menu, a level, a pause overlay — with its own objects,mapandcamera.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, asspawn_objects()hands it to the factory registered for itstype: 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
From rmp/assets.h
rmp::assets:: — loading from resources/
A sprite sheet, read straight out of an Aseprite file
SheetFrame
One frame of a sheet: where it is in the packed texture, and how long it shows.
| Field | Type | Default | What it is |
|---|---|---|---|
source | Rectangle | {} | Where this frame is in the packed texture |
seconds | float | 0 | From the file, so it plays at the speed you drew it |
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.
| Field | Type | Default | What it is |
|---|---|---|---|
name | std::string | The tag's name in Aseprite | |
from | int | 0 | The first frame, an index into |
to | int | 0 | Inclusive, the way Aseprite counts |
ping_pong | bool | false | Aseprite's "Ping-pong" direction: forwards, then back |
reverse | bool | false | Aseprite's "Reverse" direction: last frame first |
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.
| Field | Type | Default | What it is |
|---|---|---|---|
name | std::string | The slice's name in Aseprite | |
bounds | Rectangle | {} | Where it is in the PACKED texture, in pixels |
nine | bool | false | It has 9-slices: |
center | Rectangle | {} | The middle, relative to |
SpriteSheet
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
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
How rmp::find_path() looks for a way through a map.
| Field | Type | Default | What it is |
|---|---|---|---|
diagonal | bool | true | Eight directions; false = four. A corner is never cut |
clearance | float | 0 | Keeps this many units from every solid cell: half the walker's width |
find_path
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
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.
| Field | Type | Default | What it is |
|---|---|---|---|
name | std::string | "wave", "color", "speed"...: what is in the brackets first | |
position | int | 0 | The first character it covers, in code points of |
length | int | 0 | How many it covers; 0 for a self-closing [pause=0.4/] |
properties | std::vector<std::pair<std::string, std::string>> | Name = value, as written |
A property's value, or "" when the markup has none of that name.
DialogueLine
A line of the conversation, ready to show.
| Field | Type | Default | What it is |
|---|---|---|---|
id | std::string | Its #line: id, the key of its translation | |
speaker | std::string | Who says it ("Mika: ..."), or empty | |
text | std::string | What is said, in the current language, without the speaker or markup | |
markup | std::vector<DialogueMarkup> | Where the markup was, in | |
tags | std::vector<std::string> | Its #hashtags, without the # |
DialogueOption
One of the choices the player has now.
| Field | Type | Default | What it is |
|---|---|---|---|
id | std::string | Its #line: id, the key of its translation | |
text | std::string | In the current language, without markup | |
available | bool | true | False: its condition failed; shown disabled, or not at all |
markup | std::vector<DialogueMarkup> | Where the markup was, in | |
tags | std::vector<std::string> | Its #hashtags, without the # |
DialogueSaliency
How a line group (=>) or a node group (when:) picks among what can run.
| Value | Means | |
|---|---|---|
FIRST | The first whose conditions pass | |
BEST | The one with the most conditions that pass | |
LEAST_SEEN | The least seen, the most specific of those: the default | |
RANDOM_LEAST_SEEN | As 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
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.
| Value | Means | |
|---|---|---|
NONE | ||
RECTANGLE | ||
CIRCLE |
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.
| Field | Type | Default | What it is |
|---|---|---|---|
kind | ShapeKind | ShapeKind::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 |
size | Vector2 | {} | RECTANGLE: width and height |
radius | float | 0 | CIRCLE |
offset | Vector2 | {} | From the object's centre |
color | Color | WHITE | The fill, or the outline when not filled |
filled | bool | true | False draws the outline only |
thickness | float | 1 | The outline's width when filled = false; a CIRCLE ignores it |
rect, circle
The two spellings that read like what they make.
The edge of the world
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.
| Value | Means | |
|---|---|---|
NONE | The default: objects may leave, and do | |
CLAMP | Stops at the edge a paddle, a player, a cursor | |
BOUNCE | Flips the velocity a Pong or Breakout ball | |
WRAP | Comes back the other side Asteroids | |
DESTROY | Is 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
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 } });| Field | Type | Default | What it is |
|---|---|---|---|
position | Vector2 | {} | THE CENTRE, in world units |
size | Vector2 | {} | Shorthand for a RECTANGLE shape of this size |
shape | Shape | {} | The full form; used instead of |
velocity | Vector2 | {} | World units per second |
scale | Vector2 | { 1, 1 } | Multiplies the shape, the collider and the sprite |
rotation | float | 0 | Degrees, as raylib counts them |
layer | int | 0 | Draw order: a higher layer draws on top |
visible | bool | true | False: not drawn, but still updated and collided |
edges | Edge | Edge::NONE | What happens at the edge of |
bounds | Rectangle | {} | {0,0,0,0} = the map's bounds, or the view without a map |
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.
| Field | Type | Default | What it is |
|---|---|---|---|
from | Vector2 | {} | Where the ray starts, in world units |
to | Vector2 | {} | Where it ends; nothing beyond it is hit |
mask | unsigned | 0xFFFFFFFFu | The same layers as the collision pass |
ignore | Handle<Object> | {} | Normally whoever is shooting: |
solid_only | bool | false | Only objects that are Last in the struct, because added before the others it would shift a POSITIONAL initialiser — |
RayHit
RayHit lives below Object too, for the same reason.
| Field | Type | Default | What it is |
|---|---|---|---|
object | Handle<Object> | What was hit; a handle, so it is safe to keep across frames | |
point | Vector2 | {} | Where, in world coordinates |
normal | Vector2 | {} | The surface normal there, pointing back at the ray |
distance | float | 0 | From the ray's origin |
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
What else a translated text can say: the context that tells two texts with the same words apart ("Open" a door, "Open" a file).
| Field | Type | Default | What it is |
|---|---|---|---|
context | std::string_view | {} | The row's context column; empty: none |