rmp::behavior::Spawner
Produces objects every N seconds, or every N units TRAVELLED.
By distance is not the same as a Timer, and the difference is the whole reason this is not one: in an endless runner the speed climbs, so "every two seconds" puts the obstacles further and further apart and the game gets EASIER the faster you go, which is the opposite of the intention.
Added to an object with add<rmp::behavior::Spawner>(); the framework calls its _update with the object it is on.
Fields
| Field | Type | Default | What it is |
|---|---|---|---|
every_seconds | float | 0 | One of these two, not both |
every_distance | float | 0 | Units travelled between spawns; wins if both are set |
jitter | float | 0 | +/- this much, uniformly |
max_alive | int | 0 | 0 = no limit, and it is a cap on the LIVE ones |
track | Handle<Object> | Where "travelled" is measured from. Empty = this object's own position. | |
on_spawn | Callback<Scene &, Vector2> | Makes what is spawned, given the scene and where | |
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 |
alive
How many of the objects it made are still alive RIGHT NOW. It goes down when they die, which is the whole difference between a cap and a quota.
jitter_amount
A fresh random amount between -jitter and +jitter from rmp::random::range, or 0 when jitter is 0 or less or not a finite number: what each interval after the first is moved by.