Listening to Multiple Key Events simultaneously
Hello, I am currently developing a game. I have finished nearly all the programming involved, however, I still have a problem concerning Dual-Player - I would like to be able to listen to several keystrokes simultaneously so that each player would be able to move whilst the other player is performing a move himself.
PS - I am currently keeping track of events using an EventQueue of myself, which I "pushed" into the SystemEventQueue.
With Thanks,
laginimaineb.
# 2
Thanks for your reply. Yes, my problem is that queues only process one at a time. What I am looking for is a way to listen to simultaneous KeyEvents. I understand this is not possible via EventQueue and therefore I am free to any suggestions. By the way, another problem is that once one key is pressed, it keeps firing KeyEvents and all other keys which are also pressed stop firing KeyEvents. Is there a way around that or should I just keep track of all keys which are pressed until I receive an Event telling me that they were released?
With Thanks,
laginimaineb.
# 3
What I do is to have a set of booleans, one for each key used in the game. I set them to true in keyPressed() and false in keyReleased(), then I handle the booleans in the run() loop, so multiple keypresses aren't a problem;
if (m_leftPressed && m_jumpPressed) doSomething();