Currently I am starting to develop my first serious game. Before the games are all training, and learning how to do things in a good way. Unfortunatly, I've missed a big part in my preparation: Key binding.
Currently I am trying to figure out how I can bind keys to action for each scene in my game. For example: If the user presses the JumpButton during the GameScene, the avatar should jump, but pressing the same key in a MenuScene, the currently selected menuitem should be activated.
Which key the JumpButton is, should the user be able to set. But the behaviour should be always the same.
Here is my first, and I think very naviive idea:
I am having a HashMap with HashMap where Key is the key on the Keyboard and ACTION is just an enumValue. When I am in the scene, and a button is pressed, I will take that button, and ask the HashMap which action is bind to the button. using a switch I can now determine what to do. In my mind there is a little gap.. I have ONE action per Button, maybe named: ACTION_PLAYER_JUMP as an enumValue, and when I am in a GameScene this is okay, but in a MenuScene this ACTION_PLAYER_JUMP is not a very nice name... I do not want to have all bindings two times, just for better names.
Can someone tell me how to fix this, or a better system? I am sure there is a much better system for handling those bindings.