state_machine

package
v0.0.0-...-54c8723 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: GPL-3.0 Imports: 1 Imported by: 0

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)

Jump to

Keyboard shortcuts

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