Re: Best way to make a timer in python?
You can use the time module. What you do is set a baseline time variable, then compare it to the current time to see how much time has passed. For example:
import time
baseline = time.time()
while True:
if time.time() - baseline == 1:
print("one second has passed")
break
Now, to pause it you can just make baseline equal time.time() preemptively, like so:
import time
baseline = time.time() pause = True while True: if time.time() - baseline == 1: print("one second has passed") break elif pause == True: baseline = time.time()
This ensures that any checks you have that requires a certain amount of time to trigger won't go off, effectively pausing them.
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector