On this page
  1. Fields
    1. grounded

rmp::behavior::Platformer

behavior #include <rmp/behavior.h> include/rmp/behavior.h:147
struct 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

FieldTypeDefaultWhat it is
speedfloat260

Units per second while a direction is held

accelerationfloat0

0 = instant

gravityfloat2000

Units per second squared, pulling down while off the ground

jumpfloat700

The upward speed a jump starts with, in units per second

air_jumpsint0

1 = a double jump

coyote_timefloat0.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_bufferfloat0.12f

A jump pressed this long before landing still fires on landing.

leftstd::string

Which actions move and jump it. Empty = move_left, move_right and ui_accept, the actions that come as standard.

jump_actionstd::string

Which actions move and jump it. Empty = move_left, move_right and ui_accept, the actions that come as standard.

oursstruct { … }

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 { .speed = 320 } stops compiling — which is the whole design. The name is the fence.

grounded

bool grounded() const

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.