Compare commits

..

2 Commits

Author SHA1 Message Date
ae6c23b6b7 Added basic timer 2025-07-06 19:34:07 +01:00
6e70f74874 Removed all letters from Flame on Black
They all seem to be broken
2025-07-06 19:33:55 +01:00
2 changed files with 14 additions and 1 deletions

View File

@ -7,7 +7,7 @@
{"file": "Noxlock-Free.otf", "alphabet": "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "difficulty": 0.2}, {"file": "Noxlock-Free.otf", "alphabet": "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "difficulty": 0.2},
{"file": "CloisterBlack.ttf", "alphabet": "abcdefghijklmnopqrstuvwxyz", "difficulty": 0.3}, {"file": "CloisterBlack.ttf", "alphabet": "abcdefghijklmnopqrstuvwxyz", "difficulty": 0.3},
{"file": "LEDLIGHT.otf", "alphabet": "abcdefghijklmnopqrstuvwxyz", "difficulty": 0.4}, {"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": "CloisterBlack.ttf", "alphabet": "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "difficulty": 0.6},
{"file": "mevno2.ttf", "alphabet": "abcdefghijklmnopqrstuvwxyz", "difficulty": 0.8}, {"file": "mevno2.ttf", "alphabet": "abcdefghijklmnopqrstuvwxyz", "difficulty": 0.8},
{"file": "CloisterBlack.ttf", "alphabet": "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "difficulty": 0.8}, {"file": "CloisterBlack.ttf", "alphabet": "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "difficulty": 0.8},

13
game.py
View File

@ -1,5 +1,6 @@
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
import math as maths import math as maths
import numpy as np
import logging import logging
import pygame import pygame
import gameUtils import gameUtils
@ -160,6 +161,10 @@ class Game(gameUtils.Game):
for char, font in zip(captcha.chars, captcha.fonts): for char, font in zip(captcha.chars, captcha.fonts):
print(f'{char}: {font.path}') print(f'{char}: {font.path}')
# Start the timer
self.timerStart = time.perf_counter()
self.timerLength = random.randint(5, 10)
def onEvent(self, event): def onEvent(self, event):
""" """
Ran when an event is fired. 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 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 #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): def close(self):
""" """
Ran when the game closes. Ran when the game closes.