What is the best technic to handle multiple button key press with PocketFrog? And can it support diagonals?
Regards,
Kornalius
I think the generally accepted technique for handling key presses with any library is simply to set a flag on the keyDown event and do the appropriate action in the main loop. So, for diagonals you'd see two of your flags set, and so forth.
It's definitely a bad idea to do any significant processing in your key message event handles, you really want to be doing the work in the main loop, so setting flags (and of course "unsetting" them in the keyUp event handlers) is pretty standard I think.
I use a struct containing the status of all keys so I can pass a pointer neatly to my functions.
I also have a bool for each key that is kinda like a 'just went down' flag and a 'just went up' flag for doing things like menu selections.
I think it's better to have these in your key handler, just an opinion.
Are diagonal keys are passed in two WM_KEYDOWN events? Like TOP-RIGHT are two seperate key events? Or maybe diagonal keys exists?
Regards,
Kornalius
Little update, it works like a charm.
What I do is I create an array of 255 bool, then set the key index to true in the WM_KEYDOWN and set it to false in the WM_KEYUP. Then I can check the key code wheter it's true or false.
Thanx a lot guys,
Kornalius