gameloop

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartLoop

func StartLoop(handler GameHandler, updateRate time.Duration, startingState interface{}) chan<- struct{}

StartLoop is physics game loop based on https://gafferongames.com/post/fix_your_timestep/

Types

type GameHandler

type GameHandler interface {
	// Integrate handles a logical step in the game, it must return the next state of the game
	// currentState is the current state of the game.
	// t is the time in seconds
	// deltaT is the time since the last update
	Integrate(currentState interface{}, t float64, deltaT float64) interface{}

	// Render should handle all the Rendering logic of the game.
	// _note:_ only display logic should go here
	// state is the current state of the game.
	// t is the time in seconds
	// alpha is the progression in between display frames. This allows for liner interpolation.
	Render(state interface{}, t float64, alpha float64)
}

Jump to

Keyboard shortcuts

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