I've finally gotten this laser thing to work for my Space Shooter, and so far I've come across a slight problem. I've gotten the laser to position itself at the starting position correctly and move vertically perfectly. Anyway, whenever I hit the space-bar (which is the controls for shooting), it shoots the bullet/laser out, but I have to wait until the bullet clears to shoot another one.
What I want it to do is keep producing bullets until the user releases their hand on the space-bar... here's the code I have so far:
if(spacebar)
// this bool variable is set to true once the user presses the space bar
{
int frame2 = 0;
if(once2 == 0)
{
projectilex2 = x + 19;
projectiley2 = y + -35;
//Positions the bullet at the nose of the ship
}
if(frame2 == 3)
{
frame2 = 0;
}
apply_surface(projectilex2, projectiley2, ShootStuff, screen, &lazers[0]);
frame2 ++;
projectiley2--;
once2++;
if(once2 == 250)
{
once2 = 0;
spacebar = false;
}
//This will eventually get better. My shoot function is horrible lol :/
}
Does anyone have any ideas as to how I can accomplish this without having to wait for the bullet to clear before I can shoot another one :( ?