On this page
  1. Fields

rmp::behavior::Parallax

behavior #include <rmp/behavior.h> include/rmp/behavior.h:352
struct Parallax

A background layer that scrolls at its own factor and repeats itself with no seam. Twenty lines everybody writes wrong the first time: the texture has to be drawn TWICE with the offset taken modulo its width, and it has to be recomputed when the window changes size.

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

Fields

FieldTypeDefaultWhat it is
texturestd::string

A name for rmp::assets::load_texture

factorfloat0.5f

1 = scrolls with the world, 0 = pinned to the screen

speedfloat0

Units per second of its own, for a sky that drifts

yfloat0

Where the top of the strip sits

tintColorWHITE

Multiplies the texture's colours; WHITE = drawn as it is

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.