Timer for Python game

前端 未结 10 1845
伪装坚强ぢ
伪装坚强ぢ 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条回答
  •  闹比i
    闹比i (楼主)
    2021-01-31 03:09

    I use this function in my python programs. The input for the function is as example:
    value = time.time()

    def stopWatch(value):
        '''From seconds to Days;Hours:Minutes;Seconds'''
    
        valueD = (((value/365)/24)/60)
        Days = int (valueD)
    
        valueH = (valueD-Days)*365
        Hours = int(valueH)
    
        valueM = (valueH - Hours)*24
        Minutes = int(valueM)
    
        valueS = (valueM - Minutes)*60
        Seconds = int(valueS)
    
    
        print Days,";",Hours,":",Minutes,";",Seconds
    
    
    
    
    start = time.time() # What in other posts is described is
    
    ***your code HERE***
    
    end = time.time()         
    stopWatch(end-start) #Use then my code
    

提交回复
热议问题