Expand description
Screen-shake counter.
The cheapest possible “the world reacted” feedback. A single
frame counter; tick() decrements it and returns a small
(dx, dy) offset the caller adds to their vertex positions.
Triangle-wave pattern – sign flips each frame so it reads as a judder rather than a smooth drift. Magnitude decays linearly with the counter, so the last frames are subtle.
§Example
ⓘ
let mut shake = ShakeState::new();
// On impact:
shake.trigger(6);
// Every frame, folded into rendering:
let (dx, dy) = shake.tick();
draw_game_world_at_offset(dx, dy);Structs§
- Shake
State - Frame-countdown that emits a judder offset.