How would I go about writing a program that counts down in the background?

So I want to make a little game using the chrono library so i can familiarize myself with it more. What I want to do is make a game where the player can craft items and the items take time to craft. Just something very basic, text based. What i'm thinking is that the time could run on a thread, which would free the player to do other operations like buying and selling items without having to wait for the timer to countdown, but I am unsure if this is something that will work, as I dont know a ton about threads either.
you don't need a count-down for that (you can, but its overkill). you can just check the current time every so often to see if (now-time_player_started) > time_needed_to_craft .

threads are a resource of sorts, so spawning a thread per item would be a bit of a hog if the player can spam make stuff while the first is cooking. A single thread doing the time stuff would not be much different from the first thing I said, you could do it but it gains you little.

I would focus on chrono a bit, then if you want go learn threads. Mixing the two for real time processing / time based control is tricky so you want a good handle on both ideas before combining them.
Last edited on
Topic archived. No new replies allowed.