Compare commits
2 Commits
172ffc2abf
...
ae6c23b6b7
| Author | SHA1 | Date | |
|---|---|---|---|
| ae6c23b6b7 | |||
| 6e70f74874 |
@ -7,7 +7,7 @@
|
||||
{"file": "Noxlock-Free.otf", "alphabet": "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "difficulty": 0.2},
|
||||
{"file": "CloisterBlack.ttf", "alphabet": "abcdefghijklmnopqrstuvwxyz", "difficulty": 0.3},
|
||||
{"file": "LEDLIGHT.otf", "alphabet": "abcdefghijklmnopqrstuvwxyz", "difficulty": 0.4},
|
||||
{"file": "Flame on Black.ttf", "alphabet": "abcdefghijklmnopqrstuvwxyz0123456789!?/#<>", "difficulty": 0.5},
|
||||
{"file": "Flame on Black.ttf", "alphabet": "z0123456789!?/#<>", "difficulty": 0.5},
|
||||
{"file": "CloisterBlack.ttf", "alphabet": "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "difficulty": 0.6},
|
||||
{"file": "mevno2.ttf", "alphabet": "abcdefghijklmnopqrstuvwxyz", "difficulty": 0.8},
|
||||
{"file": "CloisterBlack.ttf", "alphabet": "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "difficulty": 0.8},
|
||||
|
||||
13
game.py
13
game.py
@ -1,5 +1,6 @@
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
import math as maths
|
||||
import numpy as np
|
||||
import logging
|
||||
import pygame
|
||||
import gameUtils
|
||||
@ -160,6 +161,10 @@ class Game(gameUtils.Game):
|
||||
for char, font in zip(captcha.chars, captcha.fonts):
|
||||
print(f'{char}: {font.path}')
|
||||
|
||||
# Start the timer
|
||||
self.timerStart = time.perf_counter()
|
||||
self.timerLength = random.randint(5, 10)
|
||||
|
||||
def onEvent(self, event):
|
||||
"""
|
||||
Ran when an event is fired.
|
||||
@ -193,6 +198,14 @@ class Game(gameUtils.Game):
|
||||
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
|
||||
|
||||
if self.timerLength != 0:
|
||||
timeLeft = self.timerLength - (time.perf_counter() - self.timerStart)
|
||||
normalisedTimeLeft = max(timeLeft / self.timerLength, 0)
|
||||
x = round((1-normalisedTimeLeft) * (self.size[0] // 2))
|
||||
w = normalisedTimeLeft * self.size[0]
|
||||
c = np.round((255, 255*normalisedTimeLeft, 255*normalisedTimeLeft))
|
||||
pygame.draw.rect(self.surf, c, (x, 0, w, 10))
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
Ran when the game closes.
|
||||
|
||||
Reference in New Issue
Block a user