Package MeatEngine :: Package Logic :: Module fsmMgr
[hide private]
[frames] | no frames]

Module fsmMgr

source code

Meat Engine Hierarchical Finite State Machine (hFSM) Manager

This could be refactored so that a fsmMgr is an instatiatable class, but for now it uses the "lazy singleton" pattern - the state stack is a module global, and methods are just module functions. This is adequate for my needs so far.

Use: create State objects, push them on the stack. Periodically call the update and draw functions, and pass the handleKey and handleMouseButton events in as appropriate. The top state will get delegated to, which may choose to delegate further. For example, a dialog box may choose to call the next state's draw code first, before drawing itself.

Classes [hide private]
Functions [hide private]
pushState(newState) source code
popState() source code
popAll() source code
handleKey(k, unicode) source code
handleActivate(bNowActive) source code
handleMouseButton(bDown, button) source code
update(ms) source code
draw() source code
isTop(state) source code
Variables [hide private]
  gStateStack = []