rmp::behavior::Platformer
Gravity, jumping, ground, coyote time and a buffered jump. The last two are what separates a platformer that feels right from one that does not, and neither is something a player can name — they only notice their absence.
Added to an object with add<rmp::behavior::Platformer>(); the framework calls its _ready, _update with the object it is on.
Fields
| Field | Type | Default | What it is |
|---|---|---|---|
speed | float | 260 | Units per second while a direction is held |
acceleration | float | 0 | 0 = instant |
gravity | float | 2000 | Units per second squared, pulling down while off the ground |
jump | float | 700 | The upward speed a jump starts with, in units per second |
air_jumps | int | 0 | 1 = a double jump |
coyote_time | float | 0.1f | Still jumpable for this long after walking off a ledge. Named after the coyote who keeps running for a moment past the cliff. |
jump_buffer | float | 0.12f | A jump pressed this long before landing still fires on landing. |
left | std::string | Which actions move and jump it. Empty = move_left, move_right and ui_accept, the actions that come as standard. | |
right | std::string | Which actions move and jump it. Empty = move_left, move_right and ui_accept, the actions that come as standard. | |
jump_action | std::string | Which actions move and jump it. Empty = move_left, move_right and ui_accept, the 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 |
grounded
Whether it was standing on something at its last update: a solid object or a solid map cell just under its feet, while not moving up.