Countdown timer is delayed on pygame screen?

不想你离开。 提交于 2019-12-20 07:23:22

问题


I've created a game; in which one of the main components is a countdown timer- however this timer is delayed and I am not able to deduce why.

This is how I have the timer set up:

loops = 0
minute = 1
tens = 0
ones = 0 

#Timer Calculation
    screen.blit(cloudSky, (0,0))
    if go == True:
        loops = loops + 1
        if (loops % 60)== 0:
            if ones == 0 and tens == 0 and minute != 0:
                tens = 6
                ones = 0
                minute = minute - 1

            if ones == 0 and tens != 0:
                ones = 9
                tens = tens - 1

            elif ones != 0:
                ones = ones - 1

            elif tens == 0 and ones == 0:
                tens = 5
                minute = minute - 1

            elif ones == 0 and tens != 0:
                tens = tens - 1


            if minute <= 0 and tens == 0 and ones == 0:
                go = False

#Draw Clock Time
time = timeFont.render(str (minute)+ ":" + str (tens) + str (ones), True, WHITE)
screen.blit(time, (750,10))

Any help is greatly appreciated!

来源:https://stackoverflow.com/questions/44600065/countdown-timer-is-delayed-on-pygame-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!