Help with timers in Game!
Posted: 12 Apr 2016 13:03
I am creating a real-time (more or less 24 hours=24 min) simulation game, much like an old school Tomagachi. This simulation is hugely dependent on elapsed time, as you will have to "feed" your pet every few hours or he will starve.
I understand many of the basic "timer" or "countdown" techniques available, however the difficulty is they all either pause the game, forbidding the user to interact in other ways (sleep) or they get the start/end times and if elapsed time is such and such, execute x. The second seems the best for this situation, however I can only trigger the "endtime" at the beginning of a loop. Which means that technically, the time is only ended and checked whenever a user enters that loop, which could be shorter or longer than "real-time" would allow.
Imagine the user is able to remain on a single menu. The background timer would still be counting, and if say, 10 minutes goes by, a message would be echoed and variables would change automatically (without the user doing anything).
Is this possible? Suggestions?
I understand many of the basic "timer" or "countdown" techniques available, however the difficulty is they all either pause the game, forbidding the user to interact in other ways (sleep) or they get the start/end times and if elapsed time is such and such, execute x. The second seems the best for this situation, however I can only trigger the "endtime" at the beginning of a loop. Which means that technically, the time is only ended and checked whenever a user enters that loop, which could be shorter or longer than "real-time" would allow.
Imagine the user is able to remain on a single menu. The background timer would still be counting, and if say, 10 minutes goes by, a message would be echoed and variables would change automatically (without the user doing anything).
Is this possible? Suggestions?