rmp::behavior::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
| Field | Type | Default | What it is |
|---|---|---|---|
texture | std::string | A name for | |
factor | float | 0.5f | 1 = scrolls with the world, 0 = pinned to the screen |
speed | float | 0 | Units per second of its own, for a sky that drifts |
y | float | 0 | Where the top of the strip sits |
tint | Color | WHITE | Multiplies the texture's colours; WHITE = drawn as it is |
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 |