Ugly Joe
New member
I started to poke around my shmup code again today and came across a shortcoming in GLUT. What I'm trying to do is have the ship be moved with the arrow keys, but slow down when the user holds down shift. Now, the moving part is easy, but the shift part is driving me crazy.
Glut has a function called glutGetModifiers() that you can call during your key-handling functions (but only during your key-handling functions) that will tell you if modifier keys (shift/ctrl/alt) are being held down. I can use that in the key-handler to set a "slowdown" boolean and have the game slow down the player. That almost works.
The problem is that the shift key itself does not set off the key-handlers. That is, If I were to hold shift and then hold left, the player would move slowly to the left. If were to hold left and then hold down shift, I would not slow down until I pressed another key (directional, letter, anything to set off the keyhandler function).
I've looked high and low, but can't seem to find a sane way of coding this.
I've also considered some alternatives. Like, don't use a modifier key for the slowdown button, or, use the JKLI keys for movement so that the shift key will make the character values change. The problem with both of those is that some keyboards (mine included) can only respond to a few keys at once. Using so many letter keys at once will make the game unplayable for some people.
This is almost becoming a Diaries post, so I'll stop there. If you're familiar with GLUT and know a better way of handling modifier keys, please let me know. Also, if you can think of any alternative control schemes, please let me know.
<P ID="signature"></P>
Glut has a function called glutGetModifiers() that you can call during your key-handling functions (but only during your key-handling functions) that will tell you if modifier keys (shift/ctrl/alt) are being held down. I can use that in the key-handler to set a "slowdown" boolean and have the game slow down the player. That almost works.
The problem is that the shift key itself does not set off the key-handlers. That is, If I were to hold shift and then hold left, the player would move slowly to the left. If were to hold left and then hold down shift, I would not slow down until I pressed another key (directional, letter, anything to set off the keyhandler function).
I've looked high and low, but can't seem to find a sane way of coding this.
I've also considered some alternatives. Like, don't use a modifier key for the slowdown button, or, use the JKLI keys for movement so that the shift key will make the character values change. The problem with both of those is that some keyboards (mine included) can only respond to a few keys at once. Using so many letter keys at once will make the game unplayable for some people.
This is almost becoming a Diaries post, so I'll stop there. If you're familiar with GLUT and know a better way of handling modifier keys, please let me know. Also, if you can think of any alternative control schemes, please let me know.
<P ID="signature"></P>