I'm making a fairly basic top down 2D shooting game (think Space Invaders) but I'm having an issue with KeyEvent processing too many events per second.
I have this:
if (e.getKeyCode() == KeyEvent.VK_SPACE){
shoot();
}
shoot() creates a bullet and sets it firing upward, but a problem arises if you simply hold down space to fire hundreds of bullets, making the game trivial.
Is there a way to make it process only one or two keypresses per second, ignoring the rest?