Computer Science Canada Keys |
Author: | metachief [ Sat Oct 11, 2008 11:56 am ] |
Post subject: | Keys |
I have a problem with a shooter I am making. I am trying to make a pistol fire when I press the space bar, but instead of firing once it is continuous until I release the space bar. So how would I make it so that it only fires once when I press space bar ( or in other cases other keys as well ) ? |
Author: | Clayton [ Sat Oct 11, 2008 2:27 pm ] |
Post subject: | RE:Keys |
Check to see if just before you would shoot the bullet, the spacebar (or whatever key you are using) was up (ie. not pressed). If it wasn't pressed during the last iteration of your loop, then check if it's down, if it is, shoot, otherwise, don't shoot. You'll also have to make sure that you have some variable that keeps track of pressed status. |
Author: | metachief [ Sat Oct 11, 2008 2:48 pm ] | ||
Post subject: | RE:Keys | ||
I made it work, but I'm not sure if there is a better way of doing it. Mine's kinda long. If anyone has a shorter way, please tell me.
|
Author: | Clayton [ Sat Oct 11, 2008 5:15 pm ] | ||
Post subject: | RE:Keys | ||
play around with this:
|
Author: | metachief [ Sat Oct 11, 2008 6:35 pm ] |
Post subject: | RE:Keys |
Oh, thank you! That's much better. |