Hi guys, i'm having trouble with threads, in this code when i start a thread it stops the game for 10 seconds ( the time for reloading ) and then continues.
I'm using startReloading() as a member function in Tank class.
or maybe you can suggest me a different approach ???
---------------------------------------------------------------
if( reloading == false )
{
// shoot.
}
else
{
_reloadTime = _reloadClock.restart();
reloading = true;
thread reloadThread(&Tank::startReloading, this);
reloadThread.join();
}
//...
void Tank::startReloading()
{
do
{
_reloadTime = _reloadClock.getElapsedTime();
if (_reloadTime.asSeconds() > 10)
{
crntRound = 0;
updateAmmoString();
reloading = false;
break;
}
} while (true);
}