I thought of making a race simulation where two (or more races ) start across the galaxy and try to colonize it. I have a dilemma about a timer I was trying to make to resemble the timeline, for example a second in the compiler would be a month of time in game you could say.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
int y = 1;
int timeline = 0;
int currency = 0;
int stars_clnzd = 0; // stars colonized
do {
timeline++;
currency += 75;
std::cout << timeline << " ";
Sleep(1000);
if (timeline <= 1)
{
Sleep(10000);
std::cout << "Our currency is " << currency << " ";
}
} while (y == 1);
|
I did some research online and the best thing I could find about time was the sleep function, my problem is, is that if I add an if statement saying if
timeline
reaches a certain time output this and then
Sleep(5000)
to add a 5 second delay for the output, but that doesn't work with the sleep function because every time I add some code like
Sleep(1000)
it doesn't pause output , it pauses the entire application for an extra second which I cannot work with. Sure I could add something like :
1 2 3 4
|
if (timeline == 3) // as in 3 seconds
{
std::cout << // some output
}
|
but that's too specific and would waste so much code trying to code every possible output individually. I'm just looking for a good timer in short, any suggestions?