glemy/cooldown
A plain count-down-to-zero timer – a genre-agnostic Core utility,
not part of glemy/physics, matching how every engine surveyed
(Bevy, Godot, LÖVE2D) keeps timer utilities separate from physics.
A remaining-seconds value, not an opaque type: matches
glemy/physics/entity.gleam’s own resting_time field (a plain
Float governed by a pure function, settle) and
glemy/physics/collision.gleam (a whole domain module with no type
of its own) – this repo’s own established precedent for “a domain
module is a named concept with pure functions, not necessarily an
eponymous ADT.” See decision 0049.
Values
pub fn is_ready(remaining: Float) -> Bool
Whether a cooldown counted down to remaining has fully elapsed.
pub fn tick(remaining: Float, dt: Float) -> Float
Advances remaining (seconds) by dt, floored at 0.0 – a
cooldown can’t go negative. dt is assumed non-negative (a real
per-frame value); not specially guarded against if negative, in
which case remaining increases rather than decreases.
tick(0.5, 0.2)
// -> 0.3
tick(0.1, 0.5)
// -> 0.0