rmp::behavior::TopDown
Eight directions, and the sprite chosen from the one you are facing.
The eight-way movement is free and correct because rmp::input::vector() normalises: going diagonally is NOT 41 % faster, which is the bug in half the raylib tutorials on the internet.
Added to an object with add<rmp::behavior::TopDown>(); the framework calls its _update with the object it is on.
Fields
| Field | Type | Default | What it is |
|---|---|---|---|
speed | float | 220 | Design units per second |
eight_way | bool | true | False = four directions only |
acceleration | float | 0 | 0 = instant, which is what nearly all 2D wants |
idle | std::string | "idle" | THE ANIMATION NAMES ARE YOURS: they are the tags in your .aseprite, and "idle" and "walk" are only the defaults, not a convention imposed on you. The tag actually chosen is "<walk>_<suffix>" if the sheet has it and "<walk>" with flip_x if it does not, so a two-, four- or eight-direction sheet all work with nothing configured. THE ART FACES RIGHT. flip_x is set while facing left, to mirror the frames that have no direction of their own — |
walk | std::string | "walk" | THE ANIMATION NAMES ARE YOURS: they are the tags in your .aseprite, and "idle" and "walk" are only the defaults, not a convention imposed on you. The tag actually chosen is "<walk>_<suffix>" if the sheet has it and "<walk>" with flip_x if it does not, so a two-, four- or eight-direction sheet all work with nothing configured. THE ART FACES RIGHT. flip_x is set while facing left, to mirror the frames that have no direction of their own — |
suffixes | std::array<std::string, 8> | { "e", "ne", "n", "nw", "w", "sw", "s", "se" } | THE ANIMATION NAMES ARE YOURS: they are the tags in your .aseprite, and "idle" and "walk" are only the defaults, not a convention imposed on you. The tag actually chosen is "<walk>_<suffix>" if the sheet has it and "<walk>" with flip_x if it does not, so a two-, four- or eight-direction sheet all work with nothing configured. THE ART FACES RIGHT. flip_x is set while facing left, to mirror the frames that have no direction of their own — |
left | std::string | Which actions move it. Empty = the move_* actions that come as standard. | |
right | std::string | Which actions move it. Empty = the move_* actions that come as standard. | |
up | std::string | Which actions move it. Empty = the move_* actions that come as standard. | |
down | std::string | Which actions move it. Empty = the move_* actions that come as standard. | |
ours | struct { … } | What it is keeping track of. Readable, because sometimes you want it; not yours to write. It is one PUBLIC member and not a private block because a struct with a private member is not an aggregate in C++20, and then |
direction
The last non-zero direction, normalised. What a game reads to fire a weapon the way the character is looking.
sector
Which of the eight sectors ours.facing is in, as an index into suffixes.