Game Input
Okay, so right now my game is using DirectInput and I have it working in my own class and it works all right. But I want to switch to using windows messages however I cant think of a nice way of encapsulating it.
Specifically how do I get the key states from the windows messages into my class and store them in a way that I can then use functions in the rest of my code to check if a key is down. Currently I have functions like KeyIsDownNow(DIK_A) that return whether its down or not as well as similar functions that return if the key has only been pressed this frame.
The next thing is I would like to implement it in a way that the game code can ask iskeydown(shootkey) so that I can change "shootkey" in a settings file.
If you want to emulate that functionality in your own class, the easy way would be to create your own array and set the values appropriately in WM_KEYDOWN and WM_KEYUP. To allow dynamic bindings of your keys to actions, you can create an enumeration for your action types and then create a map of some sort (in C++, std::map, unordered_map or hash_map would all work) for you actions to key codes and then use the map to index your array.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement