jsgoller1 / sprawl

2D Game Engine
GNU General Public License v3.0
0 stars 0 forks source link

Refactor input system #43

Open jsgoller1 opened 1 year ago

jsgoller1 commented 1 year ago

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