pyglet_demo/engine/control.py

21 lines
1 KiB
Python

# an input is something the player does
# it can be instantaneous (keydown, keyup)
# it can be have duration (keypressed)
# it can be analog (joystick)
# it can be positional (mouse, touch)
# a control is a function the game provides
# it allows external control over the game
# it
# a binding is the configuration for which inputs map to which controls
# it can be 1-to-1
# it can be left unmapped
# it may not apply in all contexts
# a context is a state in which a particular set of bindings are active
# it is a tree
# multiple contexts can be active, but only one will match and order matters
# it can add bindings, remove bindings, or redefine bindings from the context above it
# the root of the tree represents bindings that are universally active (unless removed)
# different branches of the tree apply to different sections of the game
# for example, an inventory screen may have its own context with additional or redefined bindings
# several context branches may inherit bindings from a common parent