diff --git a/game.py b/game.py index 963c6cc..0e45b1a 100644 --- a/game.py +++ b/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 + # Used for animating the red flash on the current character if the users enters it wrong. + self.lastWrong = 0 self.fonts = [] self.Drawsurface = Image.new("RGB",(800,220),(255,255,255)) @@ -184,6 +186,8 @@ class Game(gameUtils.Game): elif event.unicode != '' and event.unicode in alphabet: correct, finished = self.currentCaptcha.match(event.unicode) + if not correct: + self.lastWrong = time.perf_counter() print(correct) if finished: self.createCaptcha() @@ -194,7 +198,9 @@ class Game(gameUtils.Game): game logic that should be ran once per frame in here. """ - self.surf.fill((0, 0, 0)) #sets the background colour + r = 1 - min(time.perf_counter() - self.lastWrong, 1) + + self.surf.fill((r * 255, 0, 0)) #sets the background colour self.surf.blit(gameUtils.centre(self.currentCaptchaImg, self.size)) #draws the text to center of the screen #TODO: actually scale the text, however, more work needs to be done on the actual function of the game first