Added global font & render current item
This commit is contained in:
20
game.py
20
game.py
@ -131,6 +131,8 @@ class Game(gameUtils.Game):
|
||||
textSurf = rotateRad(textSurf, rad)
|
||||
# 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
|
||||
@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user