-
Notifications
You must be signed in to change notification settings - Fork 1
tstamp
Kyuchumimo edited this page Mar 18, 2022
·
5 revisions
This function depends on time Python 3.x built-in module.
tstamp -> timestamp
- timestamp : the current Unix timestamp in seconds
This function returns the number of seconds elapsed since January 1st, 1970. This can be quite useful for creating persistent games which evolve over time between plays.
#####################################
TIC["PALETTE"] = [[0x14,0x0c,0x1c], [0x44,0x24,0x34], [0x30,0x34,0x6d], [0x4e,0x4a,0x4e], [0x85,0x4c,0x30], [0x34,0x65,0x24], [0xd0,0x46,0x48], [0x75,0x71,0x61], [0x59,0x7d,0xce], [0xd2,0x7d,0x2c], [0x85,0x95,0xa1], [0x6d,0xaa,0x2c], [0xd2,0xaa,0x99], [0x6d,0xc2,0xca], [0xda,0xd4,0x5e], [0xde,0xee,0xd6]] #DB16
# title: timestamp demo
elapsed = -1
while True:
cls(15)
# Display the current time stamp
current = tstamp()
print('Timestamp: ' + str(current), 10, 10, 1)
# Calculate how long ago they last played
last = pmem(0)
if last <= 0:
last = current
if elapsed == -1:
elapsed = current - last
pmem(0, current)
# Display the elapsed time away
print('Time away: ' + str(elapsed), 10, 24, 1)
#####################################