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

@@ -14,12 +14,16 @@ class SettingsMenu(GameState):
self.show_yaw_text = self.font.render("Show Yaw: ", True, (255, 255, 255))
self.show_yaw_button = Switch(100, 100, 50, 50, self.options["show_yaw"])
self.show_health_text = self.font.render("Show Health: ", True, (255, 255, 255))
self.show_health_button = Switch(100, 150, 50, 50, self.options["show_health"])
def handle_events(self, events):
"""Handles user inputs."""
for event in events:
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
self.switch_state("start_menu")
self.show_yaw_button.handle_event(event)
self.show_health_button.handle_event(event)
self.back_button.handle_event(event)
def update(self):
@@ -29,6 +33,11 @@ class SettingsMenu(GameState):
else:
self.options["show_yaw"] = False
if self.show_health_button.get_is_toggled():
self.options["show_health"] = True
else:
self.options["show_health"] = False
# Save settings to context
self.context["options"] = self.options
@@ -38,5 +47,11 @@ class SettingsMenu(GameState):
self.screen.blit(self.show_yaw_text, (self.show_yaw_button.x + self.show_yaw_button.width + 10,
self.show_yaw_button.y))
self.show_yaw_button.draw(self.screen)
self.screen.blit(self.show_health_text, (self.show_health_button.x + self.show_health_button.width + 10,
self.show_health_button.y))
self.show_health_button.draw(self.screen)
self.back_button.draw(self.screen)