How can I make a timer for my simple game?

So I am making a small game between semesters so I don't forget everything I learned last semester. The game creates a pet and the user must feed and play with it. I have it all working but I can't change the hunger and boredom levels the way I would like. Right now it is after the user has done something 5 times. Is there a way I can have a timer start when the program begins and then have the levels change every minute? Also can this be done while the program is waiting for the user to enter something and be read in with cin?
Either or
You'll have to remember the time was last fed and then measure the difference between that and current time.
If you are doing it the console way, you have a problem, you most probably have a single thread of execution. If the timer has passed 1 minute mark, how does it transfer this information to your main program or if GUI program, how to update the display text safely?

You most likely require some multi-thread concept where the background thread keep track of the timer expiring and then posting that information to the UI thread to update the display text. Depending on which platform you use, pray they already have API to do such task. In Android, we have the Handler, AsyncTask class.

If the platform you use does not exist those API, then you need to build your own, most likely require some multi-thread library.

Or if your requirement can be made simpler then forget all I have posted :P
Topic archived. No new replies allowed.