Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InterpCallback ¶
type InterpCallback func(alpha float64)
InterpCallback is called whenever the timestep has overstepped the actual time and linear interpolation needs to be performed.
type Segmenter ¶
type Segmenter struct {
// contains filtered or unexported fields
}
Segmenter is a mechanism to get reliable fixed-interval ticks, sincefor some algorithms (like physics) having consistent intervals is a necessity.
func NewSegmenter ¶
NewSegmenter creates a new Segmenter that produces the specified fixed-interval updates.
func (*Segmenter) Update ¶
func (t *Segmenter) Update(delta time.Duration, fixedCallback UpdateCallback, interpCallback InterpCallback)
Update should be called with the actual delta time elapsed. The callback function will be called a number of times with fixed delta intervals.
type Subscription ¶
type Subscription[T any] struct { // contains filtered or unexported fields }
Subscription represents a registration for notifications.
func (*Subscription[T]) Delete ¶
func (s *Subscription[T]) Delete()
Delete removes the subscription from what it is watching.
type SubscriptionSet ¶
type SubscriptionSet[T any] struct { // contains filtered or unexported fields }
SubscriptionSet holds a list of subscribers.
func NewSubscriptionSet ¶
func NewSubscriptionSet[T any]() *SubscriptionSet[T]
NewSubscriptionSet creates a new SubscriptionSet.
func (*SubscriptionSet[T]) Clear ¶
func (s *SubscriptionSet[T]) Clear()
Clear removes all subscriptions.
func (*SubscriptionSet[T]) Each ¶
func (s *SubscriptionSet[T]) Each(fn func(callback T))
Each iterates over all subscriptions.
func (*SubscriptionSet[T]) Subscribe ¶
func (s *SubscriptionSet[T]) Subscribe(callback T) *Subscription[T]
Subscribe adds a subscription to this set.
func (*SubscriptionSet[T]) Unsubscribe ¶
func (s *SubscriptionSet[T]) Unsubscribe(subscription *Subscription[T])
Unsubscribe removes the subscription from this set.
type UpdateCallback ¶
UpdateCallback is a mechanism to receive delta time increments.
type UpdateSubscription ¶
type UpdateSubscription = Subscription[UpdateCallback]
UpdateSubscription represents a notification subscription for updates.