Added text timer

This commit is contained in:
2025-07-06 20:16:46 +01:00
parent afd1fcd6be
commit ae8b0c77a5

View File

@ -97,6 +97,8 @@ class Game(gameUtils.Game):
self.timerStart = 0
# Holds how much time the user has in total (not updated)
self.timerLength = 0
# The font used for the timer
self.timerFont = pygame.font.SysFont('', 100)
# Used for animating the red flash on the current character if the users enters it wrong.
self.lastWrong = 0
@ -219,6 +221,7 @@ class Game(gameUtils.Game):
w = normalisedTimeLeft * self.size[0]
c = np.round((255, 255*normalisedTimeLeft, 255*normalisedTimeLeft))
pygame.draw.rect(self.surf, c, (x, 0, w, 10))
self.surf.blit(self.timerFont.render(str(round(timeLeft, 1)), True, c), (0, 10))
def close(self):
"""