structTimer
struct Timer
every: float
next: float
endtimer: things that happen every so often, and things that need a rest between uses. use "timer.jamo"
A Timer fires again and again, every so many seconds, like spawning an enemy every 2 seconds. A Cooldown can be used, then needs a rest, like a gun that fires at most every 0.3 seconds. Each method has an _at version that takes the time in seconds, for a game that keeps its own clock (one that pauses, or runs in slow motion). The plain ones use seconds_since_start().
struct Timer
every: float
next: float
endstruct Cooldown
rest: float
until: float
endfunc new_timer(seconds: float): Timer
func new_timer_at(seconds: float, now: float): Timer
func Timer.ready(): bool
func Timer.ready_at(now: float): bool
True once each time it's due. A game that falls far behind gets one fire, not a burst of them
func Timer.left(): float
func Timer.left_at(now: float): float
Seconds until it's next due, never below 0
func Timer.progress_at(now: float): float
How far it is to the next fire, from 0.0 just after one to 1.0 when it's due, for bars and flashing
func Timer.restart()
func Timer.restart_at(now: float)
func new_cooldown(seconds: float): Cooldown
A cooldown starts ready to use
func Cooldown.ready(): bool
func Cooldown.ready_at(now: float): bool
func Cooldown.try_use(): bool
func Cooldown.try_use_at(now: float): bool
Uses it if it's ready, starting its rest, and says whether it was
func Cooldown.left_at(now: float): float
func Cooldown.left(): float