Added text margins

This commit is contained in:
2025-06-26 07:21:57 +01:00
parent a8814fdfe1
commit 71693518a8

View File

@ -71,6 +71,9 @@ class Game(gameUtils.Game):
font = pygame.font.SysFont('', 32) font = pygame.font.SysFont('', 32)
items = [f'Example item {i+1}' for i in range(17)] items = [f'Example item {i+1}' for i in range(17)]
# How many pixels away from the outer side of the
# circle the text should be
textMargin = 5
# Calculate circle radius # Calculate circle radius
circleR = self.wheelSurf.size[0] / 2 circleR = self.wheelSurf.size[0] / 2
@ -94,7 +97,7 @@ class Game(gameUtils.Game):
# Render the item text # Render the item text
text = font.render(item, True, (255, 255, 255)) text = font.render(item, 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(), 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
#pygame.draw.rect(textSurf, (0, 128, 255), (0, 0, textSurf.size[0], textSurf.size[1]), 1) #pygame.draw.rect(textSurf, (0, 128, 255), (0, 0, textSurf.size[0], textSurf.size[1]), 1)
#pygame.draw.line(textSurf, (255, 0, 0), (circleR, circleR), (textSurf.size[0], circleR)) #pygame.draw.line(textSurf, (255, 0, 0), (circleR, circleR), (textSurf.size[0], circleR))