0

I have an odd little bug that I can't seem to weed out. I have tried using the debugger in Eclipse, but I still can't seem to figure it out.

Basically, this is a very very basic engine for a platformer. A lot of the code is from a tutorial, but I have been slowly modifying it and making sure it is all working one little step at a time.

Right now, the problem is that when you are holding down right arrow + W + F you jump(W) to the right (Right arrow) and shoot a fireball (F). This works, however if you repeat the process on the left, you do not shoot the fireball.

I have done quite a bit of tracing, tracing when you enter the fireball loop, when you press the button, and a lot of other things. At the moment, it appears that the keypress for the F is not being registered. Of course, this may just be it isn't being updated or something else, I am not sure. I just know that the trace is not called for the key press event.

This seems to be only when the player is doing all three key presses. So normally you can shoot a fireball to the left, that works. I have uploaded the code to codesend, as it is pretty long and I didn't want to bog down Stackoverflow.

I am happy to provide any other of the code documents, I do think these four should be enough but if you think you need more I will be happy to provide it.

Thank you very much for your time.

CODE:

Abstract Class MapObject - Player extends this

Player

RPG Movement - Player movement engine

Level1State - handles the key presses

  • Have you tried using a different keyboard? Many modern keyboards can't register all multiple key combinations correctly. – kviiri Nov 13 '13 at 19:15
  • Okay, so after reading through the problem, what I can suggest is, why don't you put your keys in the list on keypressed event and on keyrelease event, delete them from the list and do necessary action. – SSC Nov 13 '13 at 19:20
  • Not sure I follow exactly :/ They are on keypressed/keyreleased but I'm not sure what you mean add/delete from list? And I have tried with 2 other keyboards since you mentioned it, the problem persists :( – Tiffany Rehsif Nov 13 '13 at 19:26
  • I mean as your keyevents are happening very fast, you could put the key in a list and on release perform the event and delete the key from the list. That's what I meant. – SSC Nov 13 '13 at 19:46
  • Hmmm, tried with a newer 3rd keyboard and it seems to work. Is there anyway to make it work on the worse keyboards them? I'm going to try rearranging the order of events and the list that you mentioned – Tiffany Rehsif Nov 13 '13 at 19:59

1 Answers1

1

Please have a look at here. This is what I meant you to do. Kindly see this and let me know if this helped you or if you still have problems.

handle multiple key presses ignoring repeated key

Community
  • 1
  • 1
SSC
  • 2,956
  • 3
  • 27
  • 43