Ok, so I'm making an asteroids game in C++ and I'm trying to make the ship shoot, but it's not really working.
1st when the game starts it automatically shoots once and when I try to limit the shooting using an integer or a boolean, it doesn't work
Here's the important part of my code
int key=0;
int steerKey=0;
int moveKey=0;
bool gameExit=false;
int shoot=false;
char p1char='-';
for(;;)
{
int p1oldx=p1x;
int p1oldy=p1y;
int bOldX=bX;
int bOldY=bY;
if (_kbhit())
key = _getch();
if (key==KEY_ARROWLEFT || key==KEY_ARROWRIGHT)
steerKey = key;
if (key==KEY_ARROWDOWN)
moveKey = key;
if (key==KEY_S && shoot==false){ //This is what's not working
shoot=true;
bX=p1x;
bY=p1y;
bdirection=pdirection;
key=0;
}