I'm making an XNA shooter game. How do I have my sprite repeatedly shoot bullets instead of waiting for one bullet to go off the screen. Do I do this with and array?
I imagine somewhere you have:
Then some methods such as:
Because of this, you are only allowing yourself one bullet at a time. What you want to do, since I imagine you aren't looking for the most efficient method, is to do the following.
In your constructor put:
Then do the following:
This will maintain a list of bullets you can keep track of, and when the bullet is no longer on screen (this is where you need to put in logic to determine if a bullet is off screen) it removes it from the list of bullets.
You could create a timer class, then invoke the timer so when it's finished, the timer allows the next bullet to be shot.
I'm pretty sure this would work Create a separate class named Timer and put this in it.
Then Invoke the timer class in the main game class.
The bulletready boolean value is for so you can shoot again. If it is true, You can shoot, vice versa.
Basically, for the invoke, Create the timer's variable, Create a new instance in the initialization, Then in update, check for gamepad input, and if the bulletready is true, start a timer for the amount of time you want the bullet to be on cool down.