Created WheelItem class

This commit is contained in:
2025-06-26 14:48:33 +01:00
parent e8ee151267
commit 471de3ef6e

14
game.py
View File

@ -46,6 +46,10 @@ def rotateDeg(surface: pygame.Surface, degrees: float) -> pygame.Surface:
rotSurface = gameUtils.centre(rotSurface, surface.size)
return rotSurface
class WheelItem:
def __init__(self, text):
self.text = text
class Game(gameUtils.Game):
def __init__(self, *args, **kwargs):
"""
@ -81,7 +85,13 @@ class Game(gameUtils.Game):
font = pygame.font.SysFont('', 32)
self.items = [f'Example item {i+1}' for i in range(13)]
self.items = []
self.items.append(WheelItem('Drink 1 shot'))
self.items.append(WheelItem('Drink 2 shots'))
self.items.append(WheelItem('Get shocked at 50%'))
self.items.append(WheelItem('Get shocked at 100%'))
self.items.append(WheelItem('Get slapped by\neveryone in the room'))
self.items.append(WheelItem('Respin, wheel hidden'))
# How many pixels away from the outer side of the
# circle the text should be
textMargin = 5
@ -110,7 +120,7 @@ class Game(gameUtils.Game):
# Create a surface that our text will be rendered onto
textSurf = pygame.Surface(self.wheelSurf.size, pygame.SRCALPHA)
# Render the item text
text = font.render(item, True, (255, 255, 255))
text = font.render(item.text, True, (255, 255, 255))
# Draw the item text onto the text surface, centred to the right
textSurf.blit(text, (textSurf.size[0]-text.get_width()-textMargin, self.size[1]//2 - text.get_height()//2))
# Draw debug lines