Added global font & render current item

This commit is contained in:
2025-06-26 14:50:41 +01:00
parent 471de3ef6e
commit a1c5641eee

20
game.py
View File

@ -132,6 +132,8 @@ class Game(gameUtils.Game):
# Blit the text surface to the wheel surface
self.wheelSurf.blit(textSurf, (0, 0))
self.font = pygame.font.SysFont('', 50)
def spinnerTick(self):
# If there's a tick already playing
if time.perf_counter() - self.lastTickTime < self.tickSfx.get_length():
@ -169,15 +171,17 @@ class Game(gameUtils.Game):
self.wheelRotation += speed * self.timeDelta
self.wheelRotation %= 360
# Calculates the current item index with... I don't know, magic?
currentItemIdx = round((self.wheelRotation / 360) * len(self.items)) % len(self.items)
# Calculates the current item index with... I don't know, magic?
currentItemIdx = round((self.wheelRotation / 360) * len(self.items)) % len(self.items)
# If the last tick was on a different index,
if currentItemIdx != self.lastTickItem:
# Click again
self.spinnerTick()
# And set the last tick index to the current one
self.lastTickItem = currentItemIdx
# If the last tick was on a different index,
if currentItemIdx != self.lastTickItem:
# Click again
self.spinnerTick()
# And set the last tick index to the current one
self.lastTickItem = currentItemIdx
self.surf.blit(self.font.render(self.items[currentItemIdx].text, True, (255, 255, 255)), (0, 0))
def close(self):
"""