While we don't support key rebinding, mouse clicking, and a UI system, input is straightforward: each input key triggers a single GameAction. Here are some problems that will come up in the future.
Basics
Multiple actions can occur at once; moving and shooting, jumping and moving, etc. We will solve this in #38.
Key rebinding
Users should be able to both specify and modify which keys cause which in game behaviors.
Input can translate to UI or game world behavior
A particular key or button press will have different behavior depending on UI system state. Example: if a menu is open, up arrow moves a menu cursor instead of moving the character. Not every input should trigger a game action.
Difference in UI vs game world will be game specific
Some games may differ on behavior based on mouse position; if a menu is open, the player might still be able to move but clicking within the menu may have different behavior than clicking the game world. Sprawl may need to support different behaviors simultaneously; we should be able to use it to create:
Chrono Trigger: arrow keys only, and menus open means only interacting with menu, not game world
Missile Command: mouse only; no menus; click in game world means game world
Worms: arrow keys and mouse typically in game world, but can be used to bring up menus as well
Factorio: mouse and arrow keys, arrow keys for game world only, but some keys modify task bar. Click in menu means menu, click in world means world
Interrupts will go away
Right now, some inputs trigger behavior (quitting, pausing, etc) that goes outside the UI or game system. Both of these should just bring up a pause menu in most cases; directly quitting the game from a single keystroke isn't a feature to support long-term.
Approaches
InputManager should emit InputEvents, which the UI System and World will receive as parameters
InputEvents are then passed to the UI system.
UI system emits the remaining input events it didn't do anything with to World
We can safely make the assumption that an InputEvent handled by the UI system should not then be propagated to World, and ones meant for World can be ignored by the UI.
While we don't support key rebinding, mouse clicking, and a UI system, input is straightforward: each input key triggers a single GameAction. Here are some problems that will come up in the future.
Basics
Multiple actions can occur at once; moving and shooting, jumping and moving, etc. We will solve this in #38.
Key rebinding
Users should be able to both specify and modify which keys cause which in game behaviors.
Input can translate to UI or game world behavior
A particular key or button press will have different behavior depending on UI system state. Example: if a menu is open, up arrow moves a menu cursor instead of moving the character. Not every input should trigger a game action.
Difference in UI vs game world will be game specific
Some games may differ on behavior based on mouse position; if a menu is open, the player might still be able to move but clicking within the menu may have different behavior than clicking the game world. Sprawl may need to support different behaviors simultaneously; we should be able to use it to create:
Interrupts will go away
Right now, some inputs trigger behavior (quitting, pausing, etc) that goes outside the UI or game system. Both of these should just bring up a pause menu in most cases; directly quitting the game from a single keystroke isn't a feature to support long-term.
Approaches