ADD show health option

This commit is contained in:
2025-04-20 21:45:41 +02:00
parent 40b86ebf86
commit 69cae0044a
6 changed files with 28 additions and 8 deletions

View File

@@ -13,6 +13,7 @@ class HorizontalSlider:
self.background_colour = (255, 255, 255)
self.knob_colour = (255, 0, 0)
self.rect_radius = 5
self.knob_radius = 10
self.knob_x = self.x
@@ -39,10 +40,10 @@ class HorizontalSlider:
Draw the slider on the screen
"""
if self.fill:
pygame.draw.rect(self.screen, self.fill_colour, (self.x, self.y, self.knob_x, self.height))
pygame.draw.rect(self.screen, self.background_colour, (self.knob_x, self.y, self.width - (self.knob_x - self.x), self.height))
pygame.draw.rect(self.screen, self.fill_colour, (self.x, self.y, self.knob_x, self.height), border_radius=self.rect_radius)
pygame.draw.rect(self.screen, self.background_colour, (self.knob_x, self.y, self.width - (self.knob_x - self.x), self.height), border_radius=self.rect_radius)
else:
pygame.draw.rect(self.screen, self.background_colour, (self.x, self.y, self.width, self.height))
pygame.draw.rect(self.screen, self.background_colour, (self.x, self.y, self.width, self.height), border_radius=self.rect_radius)
pygame.draw.circle(self.screen, self.knob_colour, (int(self.knob_x), self.y + self.height // 2), self.knob_radius)
def set_value(self, value):

View File

@@ -12,6 +12,7 @@ class Switch:
self.is_toggled = default_value
self.background_colour = (211,211,211)
self.foreground_colour = (150, 150, 150)
self.active_border_colour = (255, 0, 0)
self.border_width = 1
self.border_radius = 3
self.toggle_speed = 5
@@ -78,7 +79,7 @@ class Switch:
self.rect_offset -= self.toggle_speed
elif self.is_toggled:
# Draw border
pygame.draw.rect(screen, (255, 0, 0), (self.x-self.border_width,
pygame.draw.rect(screen, self.active_border_colour, (self.x-self.border_width,
self.y-self.border_width,
self.width+(self.border_width*2),
self.height+(self.border_width*2)),