Version: v0.11.2 Latest Latest

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

Go to latest
Published: Nov 12, 2022 License: MIT Imports: 8 Imported by: 6




This section is empty.


This section is empty.


This section is empty.


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) 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) Draw added in v0.8.0

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

Draw draws the screen after a state update

func (*StateMachine) Update

func (sm *StateMachine) Update(world w.World)

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
	// TransPush pauses the active state and add new states to the stack
	// TransSwitch removes the active state and replace it by a new one
	// TransReplace removes all states and insert a new stack
	// TransQuit removes all states and quit

type Transition

type Transition struct {
	Type      TransType
	NewStates []State

Transition is a state transition

Source Files

Jump to

Keyboard shortcuts

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