Timer for Python game

前端 未结 10 1940
伪装坚强ぢ
伪装坚强ぢ 2021-01-31 02:38

I\'m trying to create a simple game where the point is to collect as many blocks as you can in a certain amount of time, say 10 seconds. How can I get a timer to begin ticking a

10条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-31 03:10

    This is the Shortest Way I know of doing it:

    def stopWatch():
            import time
            a = 0
            hours = 0
            while a < 1:
                for minutes in range(0, 60):
                    for seconds in range(0, 60):
                        time.sleep(1)
                        print(hours,":", minutes,":", seconds)
            hours = hours + 1
    

提交回复
热议问题