I started using pygame and I want to do simple game. One of the elements which I need is countdown timer. How can I do the countdown time (eg 10 seconds) in PyGame?
There are several ways you can do this- here's one. Python doesn't have a mechanism for interrupts as far as I know.
import time, datetime timer_stop = datetime.datetime.utcnow() +datetime.timedelta(seconds=10) while True: if datetime.datetime.utcnow() > timer_stop: print "timer complete" break