Skip to main content

Module powerup

Module powerup 

Source
Expand description

Unified powerup model — replaces the old per-variant slots (GoldenCuque[3] + GreenCoin) with a single Vec<Powerup> keyed by PowerupKind.

Adding a new kind is a single-file change: extend PowerupKind, give it lifetime_ticks / mean_cooldown_ticks, add a render branch, and add a catch-effect arm in GameState::catch_powerup. Every other system — input routing, tick loop, persistence, achievements — inherits the new kind without further plumbing.

Spawn timing is truncated exponential per kind, sampled inter-arrival (one RNG draw per spawn, not a per-tick roll). Per-kind cooldown clocks tick independently and don’t freeze when the kind already has on-screen instances — the Vec is unbounded and pile-ups self-resolve via the short lifetime.

Structs§

Powerup
One on-screen powerup. Position is biscuit-fractional ([0, 1] on each axis), same convention as Particle and the old GoldenCuque — the marker stays anchored to its spot when the terminal resizes or the user zooms.

Enums§

PowerupKind
Stable discriminator for every kind of powerup. Order also defines the indexing into GameState::powerup_cooldowns: [u32; N_KINDS], so don’t reorder once shipped — a save written under one ordering would index a different kind’s cooldown after a swap. (Cooldowns are #[serde(skip)] today, so the actual blast radius is “fresh-load reseeds them anyway,” but treat the order as stable to keep test fixtures honest.)

Constants§

N_KINDS
Number of distinct powerup kinds — must match PowerupKind::ALL.len(). Used to size GameState::powerup_cooldowns.

Functions§

next_cooldown
Sample the next inter-arrival cooldown for this kind. Truncated exponential: Exp(1/mean) clamped to [min, max] safety rails.