Documentation ¶
Overview ¶
The loop package provides a simple fixed-timestep event loop.
Index ¶
Constants ¶
const ( DefaultDT time.Duration = time.Second / 240 DefaultMaxFT time.Duration = time.Second )
Default timings for RunFixedStep
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventProcessor ¶
type EventProcessor interface {
ProcessEvents() (quit bool)
}
EventProcessor wraps the ProcessEvents method.
It is up to the implementation to either poll events or wait for events. Applications using a wait-for-event model should however only use the Simple event loop.
Graphical applications that need to swap buffers should swap their buffers in their ProcessEvents method, before actually processing events.
type FixedStep ¶
type FixedStep struct { Simple MaxFT time.Duration // maximum frame time DT time.Duration // timestep }
func (*FixedStep) Run ¶
func (l *FixedStep) Run(a FixedStepUpdater)
type FixedStepUpdater ¶
type FixedStepUpdater interface { EventProcessor Update(timestep time.Duration) Draw(frameTime, partialTimestep time.Duration) }
type FrameStarter ¶
FrameStarter is the interface implemented by any App that wants the time stamp at the beginning of each loop iteration.
type Simple ¶
type Simple struct {
// contains filtered or unexported fields
}
Simple provides a very simple event loop suited for applications that use a wait-for-event model.
func (*Simple) MinFrameTime ¶
MinFrameTime sets the minimum frame time.
If the t value is greater than 0, the frame rate will be clamped to time.Second/t.
func (*Simple) Run ¶
func (l *Simple) Run(a SimpleUpdater)
type SimpleUpdater ¶
type SimpleUpdater interface { EventProcessor Update() Draw() }