I'm developing a game controlled by keyboard and I have the following problem: if 2 keys are pressed simultaneously and then one of them released, I cannot detect which one is still pressed and which one is released.
I mention that the algorithm already existent on this site regarding the detection of the released key doesn't work fine in such situations.
not sure if you're going to get around that one, maybe trim down the number of keys that would be pressed at the same time? one way to do this is toggle weapons, for example have two or more weapons you could switch, instead of having them all available, which would slim the chances of them pressing more than one key at a time.
another work around is use the mouse click as well as key presses.
Thank you for your quick answer. My problem still exists, unfortunately, because I have to move an object only by using the arrow keys in 8 different directions (top, top-left, left, bottom-left, etc...)....
Any suggestion is welcome.
i would use keyboard keys instead of arrow keys, as is done in many games. this way you could map 8 adjacent keys that would be pressed independent of each other.
another option would be to use the left and right arrows to rotate your character and up and down to move up and back.
Well, you could always create a list of boolean variables like
key_left
key_right
key_space
etc... and if the key is pressed, set the value to TRUE. Then, multiple keys can have the TRUE state.. and you can loop through and respond to the states of the keys..