Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type State ¶
type State interface { Enter(data ...interface{}) Render(win *pixelgl.Window) Exit() Update(dt float64) IsFinished() bool }
StateMachine - a state machine
Usage:
gStateMachine = StateMachine:Create
{ ['MainMenu'] = function() return MainMenu:Create() end, ['InnerGame'] = function() return InnerGame:Create() end, ['GameOver'] = function() return GameOver:Create() end, }
gStateMachine:Change("MainGame")
type StateMachine ¶
type StateMachine struct { Current State // contains filtered or unexported fields }
StateMachine Controller
func Create ¶
func Create(states map[string]func() State) *StateMachine
func (*StateMachine) Change ¶
func (s *StateMachine) Change(stateName string, enterParams ...interface{})
Change state e.g. Controller.Change("move", {x = -1, y = 0})
func (*StateMachine) Enter ¶
func (s *StateMachine) Enter(data ...interface{})
func (*StateMachine) Exit ¶
func (s *StateMachine) Exit()
func (StateMachine) IsFinished ¶
func (s StateMachine) IsFinished() bool
func (*StateMachine) Render ¶
func (s *StateMachine) Render(win *pixelgl.Window)
func (*StateMachine) Update ¶
func (s *StateMachine) Update(dt float64)
Click to show internal directories.
Click to hide internal directories.