Added text timer
This commit is contained in:
3
game.py
3
game.py
@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user