We'll achieve this by keeping track of when the game was most recently running.
We'll declare a global variable:
When the game stops running, the variable will be left set at the last time it was running.
We haven't discussed dates and times before, but here's some good information available here and here.
The important thing for us right now is to know that date/times are internally stored as the number of milliseconds (thousandths of a second) since January 1st, 1970.
That might seem odd to us humans, but computers often represent date/times like that. The beauty of the system is you can easily subtract two dates and find the number of milliseconds between them.
|