# rmp

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

Source: https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html

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`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-SheetData.html) — Everything read out of an .aseprite: the packed texture, the frames and the tags.
- [`rmp::DialogueValue`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-DialogueValue.html) — A value of the Yarn language: a number, a string or a bool.
- [`rmp::Dialogue`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Dialogue.html) — A conversation: a compiled Yarn script, where it is in it, and what it remembers.
- [`rmp::Sprite`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Sprite.html) — 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`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Callback.html) — 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`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Condition.html) — 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`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Ref.html) — An optional reference: something that may not be there, and is not yours.
- [`rmp::Handle`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Handle.html) — A reference to an object that is safe to keep across frames.
- [`rmp::Object`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Object.html) — An entity in a scene: the player, an enemy, a bullet, a coin, a platform.
- [`rmp::Value`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Value.html) — 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`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Camera.html) — The camera
- [`rmp::Scene`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Scene.html) — A screen of the game — a main menu, a level, a pause overlay — with its own objects, `map` and `camera`.
- [`rmp::TextArg`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-TextArg.html) — One placeholder's value: a name and a number or a text.
- [`rmp::Text`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Text.html) — A text the framework draws: translated when it was a literal, as it is when it was made at runtime.
- [`rmp::MapObject`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-MapObject.html) — 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`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Tilemap.html) — 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`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-assets.html) — rmp::Dialogue -- conversations written in Yarn Spinner 3.
- [`rmp::save`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-save.html) — rmp/save.h — rmp::Value, and saving the game.
- [`rmp::lang`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-lang.html) — 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`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#global)<T>() — the state that outlives a scene change

```cpp
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`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#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`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#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()

function [include/rmp/app.h:240](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/app.h#L240-L254)

## From `rmp/assets.h`

`rmp::assets::` — loading from resources/

## A sprite sheet, read straight out of an Aseprite file

### `SheetFrame`

struct SheetFrame

struct [include/rmp/assets.h:241](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/assets.h#L241-L244)

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`

struct SheetTag

struct [include/rmp/assets.h:248](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/assets.h#L248-L254)

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 [`SheetData::frames`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-SheetData.html#frames) |
| `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`

struct SheetSlice

struct [include/rmp/assets.h:260](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/assets.h#L260-L265)

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()`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-ui.html#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` is its middle |
| `center` | `Rectangle` | `{}` | The middle, relative to `bounds`; only when `nine` |

### `SpriteSheet`

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

alias [include/rmp/assets.h:311](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/assets.h#L311)

A loaded sprite sheet, from [`rmp::assets::load_sheet()`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-assets.html#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>

alias [include/rmp/assets.h:319](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/assets.h#L319)

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`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#Texture), [`rmp::Image`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#Image), [`rmp::Font`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#Font) and [`rmp::Sound`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#Sound) come from the loaders in [`rmp::assets`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-assets.html) below. Nothing in [`rmp::assets`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-assets.html) returns an [`rmp::Music`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#Music), [`rmp::Shader`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#Shader) or [`rmp::RenderTexture`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#RenderTexture); music is played by name through [`rmp::audio`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-audio.html) instead.

## From `rmp/behavior.h`

rmp/behavior.h — the catalogue.

### `PathOptions`

struct PathOptions

struct [include/rmp/behavior.h:71](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/behavior.h#L71-L75)

How [`rmp::find_path()`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#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`

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

function [include/rmp/behavior.h:82](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/behavior.h#L82-L83)

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`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Dialogue.html) — conversations written in Yarn Spinner 3.

### `DialogueMarkup`

struct DialogueMarkup

struct [include/rmp/dialogue.h:103](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/dialogue.h#L103-L112)

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 `text` |
| `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 |

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

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

### `DialogueLine`

struct DialogueLine

struct [include/rmp/dialogue.h:115](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/dialogue.h#L115-L122)

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 `text` |
| `tags` | `std::vector<std::string>` |  | Its #hashtags, without the # |

### `DialogueOption`

struct DialogueOption

struct [include/rmp/dialogue.h:125](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/dialogue.h#L125-L131)

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 `text` |
| `tags` | `std::vector<std::string>` |  | Its #hashtags, without the # |

### `DialogueSaliency`

enum class DialogueSaliency : std::uint8_t

enum [include/rmp/dialogue.h:134](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/dialogue.h#L134-L139)

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`

enum class ShapeKind

enum [include/rmp/object.h:69](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L69)

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`

struct Shape

struct [include/rmp/object.h:75](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L75-L87)

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()`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#rect) and [`circle()`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#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 [`rect()`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#rect)/[`circle()`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#circle) set it, then the sizing, then the appearance. |
| `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`

Shape rect(Vector2 size)

Shape circle(float radius)

function [include/rmp/object.h:90](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L90)

The two spellings that read like what they make.

## The edge of the world

### `Edge`

enum class Edge

enum [include/rmp/object.h:157](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L157-L163)

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`

struct ObjectOptions

struct [include/rmp/object.h:607](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L607-L618)

The starting values [`Scene::spawn()`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Scene.html#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`:

```cpp
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 `size` when set |
| `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` |
| `bounds` | `Rectangle` | `{}` | {0,0,0,0} = the map's bounds, or the view without a map |

### `RayQuery`

struct RayQuery

struct [include/rmp/object.h:946](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L946-L965)

What [`Scene::raycast()`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Scene.html#raycast) and [`Scene::raycast_all()`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Scene.html#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()`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Tilemap.html#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: `.ignore = self.handle()`. Empty ignores nothing, and so does the handle of an object that is gone. |
| `solid_only` | `bool` | `false` | 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

struct [include/rmp/object.h:968](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L968-L976)

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 |

explicit operator bool() const

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

## From `rmp/text.h`

[`rmp::Text`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Text.html) and [`rmp::lang`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-lang.html) — the game in more than one language.

### `TextOptions`

struct TextOptions

struct [include/rmp/text.h:47](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/text.h#L47-L49)

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 |
