Back to godoc.org

Package states

v0.7.0
Latest Go to latest

The latest major version is .

Published: Jun 18, 2020 | License: MIT | Module: github.com/x-hgg-x/goecsengine

Index

type State

type State interface {
	// Executed when the state begins
	OnStart(world w.World)
	// Executed when the state exits
	OnStop(world w.World)
	// Executed when a new state is pushed over this one
	OnPause(world w.World)
	// Executed when the state become active again (states pushed over this one have been popped)
	OnResume(world w.World)
	// Executed on every frame when the state is active
	Update(world w.World, screen *ebiten.Image) Transition
}

State is a game state

type StateMachine

type StateMachine struct {
	// contains filtered or unexported fields
}

StateMachine contains a stack of states. Only the top state is active.

func Init

func Init(s State, world w.World) StateMachine

Init creates a new state machine with an initial state

func (*StateMachine) Update

func (sm *StateMachine) Update(world w.World, screen *ebiten.Image)

Update updates the state machine

type TransType

type TransType int

TransType is a transition type

const (
	// TransNone does nothing
	TransNone TransType = iota
	// TransPop removes the active state and resume the next state
	TransPop
	// TransPush pauses the active state and add new states to the stack
	TransPush
	// TransSwitch removes the active state and replace it by a new one
	TransSwitch
	// TransReplace removes all states and insert a new stack
	TransReplace
	// TransQuit removes all states and quit
	TransQuit
)

type Transition

type Transition struct {
	Type      TransType
	NewStates []State
}

Transition is a state transition

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier