loop

package
v0.0.0-...-24e800f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2019 License: ISC Imports: 1 Imported by: 0

Documentation

Overview

The loop package provides a simple fixed-timestep event loop.

Index

Constants

View Source
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

type FrameStarter interface {
	FrameStart(time.Time)
}

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

func (l *Simple) MinFrameTime(t time.Duration)

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()
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL