Created WheelItem class
This commit is contained in:
14
game.py
14
game.py
@ -46,6 +46,10 @@ def rotateDeg(surface: pygame.Surface, degrees: float) -> pygame.Surface:
|
|||||||
rotSurface = gameUtils.centre(rotSurface, surface.size)
|
rotSurface = gameUtils.centre(rotSurface, surface.size)
|
||||||
return rotSurface
|
return rotSurface
|
||||||
|
|
||||||
|
class WheelItem:
|
||||||
|
def __init__(self, text):
|
||||||
|
self.text = text
|
||||||
|
|
||||||
class Game(gameUtils.Game):
|
class Game(gameUtils.Game):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -81,7 +85,13 @@ class Game(gameUtils.Game):
|
|||||||
|
|
||||||
font = pygame.font.SysFont('', 32)
|
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
|
# How many pixels away from the outer side of the
|
||||||
# circle the text should be
|
# circle the text should be
|
||||||
textMargin = 5
|
textMargin = 5
|
||||||
@ -110,7 +120,7 @@ class Game(gameUtils.Game):
|
|||||||
# Create a surface that our text will be rendered onto
|
# Create a surface that our text will be rendered onto
|
||||||
textSurf = pygame.Surface(self.wheelSurf.size, pygame.SRCALPHA)
|
textSurf = pygame.Surface(self.wheelSurf.size, pygame.SRCALPHA)
|
||||||
# Render the item text
|
# 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
|
# 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))
|
textSurf.blit(text, (textSurf.size[0]-text.get_width()-textMargin, self.size[1]//2 - text.get_height()//2))
|
||||||
# Draw debug lines
|
# Draw debug lines
|
||||||
|
|||||||
Reference in New Issue
Block a user