I know I asked something about a timer a while ago, but after rewriting something I have been working on (I am writing a game for fun so I can learn more about programming) I have come to the point where I need to figure out how to do something to really make it into a game.
Currently, my "game" has status bars, "Hunger", "Happiness", "Comfort", and "Cleanliness" (I guess that reveals a little bit!).
Now, what I need to happen is to make these statuses regenerate so you must interact with the object to make them go back up.
I understand about using a timer in the loop that then goes and updates the statuses, but the problem is, if I display a menu of options to do in the loop, and the program is waiting for user input, I don't know how to have the timer run and update the statuses when the user is deciding what to do.
For example:
Hunger: 25
"Oh know I better feed it!", user puts in prompt to feed it and cannot decide what to feed it. 5 minutes go buy and the user still hasn't decided.
During this time, that hunger level should go down 1 (lets say every 1 second to be clear, though this will not be the case), how would I update this when the user is idle or trying to decide something? Do I have to use threading?
Sorry if this is a newbie question, but I it has stumped me!
Currently, my "game" has status bars, "Hunger", "Happiness", "Comfort", and "Cleanliness" (I guess that reveals a little bit!).
Now, what I need to happen is to make these statuses regenerate so you must interact with the object to make them go back up.
I understand about using a timer in the loop that then goes and updates the statuses, but the problem is, if I display a menu of options to do in the loop, and the program is waiting for user input, I don't know how to have the timer run and update the statuses when the user is deciding what to do.
For example:
Hunger: 25
"Oh know I better feed it!", user puts in prompt to feed it and cannot decide what to feed it. 5 minutes go buy and the user still hasn't decided.
During this time, that hunger level should go down 1 (lets say every 1 second to be clear, though this will not be the case), how would I update this when the user is idle or trying to decide something? Do I have to use threading?
Sorry if this is a newbie question, but I it has stumped me!