计时器可以工作,但我无法以 00:00 格式显示它 - 目前,它以十进制格式显示时间,例如:2.547959356:688.9846939
while True: # main game loop
mouseClicked = False
DISPLAYSURF.fill(BGCOLOR) # drawing the window
drawBoard(mainBoard, revealedBoxes)
counting_time = pygame.time.get_ticks() - start_time
# change milliseconds into minutes, seconds
counting_seconds = str(counting_time/1000 ).zfill(2)
counting_minutes = str(counting_time/60000).zfill(2)
counting_string = "%s:%s" % (counting_minutes, counting_seconds)
counting_text = font.render(str(counting_string), 1, (0,0,0))
DISPLAYSURF.blit(counting_text,(350,3))
pygame.display.update()
clock.tick(25)