Simple game help

I am trying to make a simple console application game in which you own a village. It's basically a Tribal Wars rip off , in case you have played it. Basically , you have mines which bring you resources and you need resources in order to build the buildings.
What I did was make an infinite while loop in which all your buildings' levels are displayed and you have to press a button ( decision=_getch()) in order to choose the building to interract with. Also , at the beginning of the while loop I set up a rate at which the resources grow (wood++ every 2 seconds and so on). The problem is that the resources do not increase every 2 seconds because the program is waiting for the user to press the key in order to interract with the building. I get one iteration , then it stops. How can I make the the std::thread function to work separately from the while loop so that the resources can continue increasing even if I haven't pressed the decision key ?
In case you did not understand , the program looks something like this :

int main ()
{
int wood=0;
char decision;
while (1)
{
wood++;
cout<<1.Building1<<endl;
cout<<2.Building2<<endl;
decision=_getch();
std::this_thread::sleep_for (std::chrono::seconds(2));
}
}





Last edited on
Please do not post more than once: http://www.cplusplus.com/forum/general/217051/
Topic archived. No new replies allowed.