Documentation ¶
Overview ¶
Package deltat ("delta T") implements simple "elapsed-time" loop helpers. The "delta" can be any number type, and the calculation provided arbitrarily. deltat also provides basic implementations of this
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Loop ¶
func Loop[D constraints.Integer | constraints.Float]( clock WallClock, calcDelta DeltaCalculator[D], do DeltaFn[D], )
The Loop calculates the elapsed D between prev and now using the provided DeltaCalculator, then passes that value to the provided DeltaFn. It exits when the DeltaFn returns `false`.
Types ¶
type DeltaCalculator ¶
A DeltaCalculator returns the elapsed D between prev and now
func ByElapsed ¶
func ByElapsed() DeltaCalculator[time.Duration]
ByElapsed is a DeltaCalculator that simply returns the elapsed time.Duration since the previous iteration.
func ByTick ¶
func ByTick(tps float32) DeltaCalculator[float32]
ByTick is a DeltaCalculator that returns how many ticks have elapsed since the last iteration. tps sets this value.
type DeltaFn ¶
A DeltaFn performs some action based on the delta provided. It returns whether it should continue into the next iteration.
type Numeric ¶
type Numeric interface { constraints.Float | constraints.Integer }
A Numeric is any float or int type.