On this page
  1. Fields
    1. distance
    2. ducking

rmp::behavior::Runner

behavior #include <rmp/behavior.h> include/rmp/behavior.h:193
struct Runner

Constant forward motion that SPEEDS UP over time, with a jump and a duck.

A Platformer with the x fixed is not this, and the difference is accelerate and distance(): in an endless runner the speed climbs on its own, and the distance travelled is both the score and the clock the difficulty hangs off — and a Spawner with every_distance and track set to the runner produces by that same distance rather than by time.

Added to an object with add<rmp::behavior::Runner>(); the framework calls its _ready, _update with the object it is on.

Fields

FieldTypeDefaultWhat it is
speedfloat320

Units per second, right now

acceleratefloat6

How much speed gains per second. 0 = constant

max_speedfloat900

The most speed is allowed to reach, units per second

gravityfloat2200

Units per second squared, pulling down while off the ground

jumpfloat720

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

air_jumpsint0

1 = a double jump

jump_actionstd::string

Empty = ui_accept

duck_actionstd::string

Held to duck; empty = it never ducks

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.

distance

float distance() const

How far it has run, in units: speed summed over every update since it was added. It counts the running, not where the object got to.

ducking

bool ducking() const

Whether duck_action was held at its last update. That is all ducking does here: a smaller collider or another animation is the game's to set.