I'm new to programming and to help learn it I have been building an 'escape room' game using Python. I have the following that runs the bomb on a seperate thread.
import time
import threading
from threading import Thread
def countdown(t):
while t:
mins, secs = divmod(t, 60)
timeformat = '{:02d}:{:02d}'.format(mins, secs)
time.sleep(1)
t -= 1
print """
The bomb goes off
GAME OVER
"""
Then in the main programme
t=3600 #60 minute game
game_thread=Thread(target=countdown,args=(t,))
game_thread.start()
What I would like to do is make it possible for the player to check how much time is left on the timer and for the timer to stop when the player has defused the bomb. Does anyone have any advice on how I can do that?
Thanks