from game.screens.base_screen import BaseScreen import pygame as pg import pygame_gui as pgi class MainMenu(BaseScreen): def __init__(self, game): super().__init__(game) manager = game.ui_manager width, height = pg.display.get_surface().get_size() # Größen title_width = 400 title_height = 80 button_width = 250 button_height = 60 center_x = width // 2 self.title = pgi.elements.UILabel( relative_rect=pg.Rect( center_x - title_width // 2, int(height * 0.2), title_width, title_height ), text="MAIN MENU", manager=manager ) self.play_button = pgi.elements.UIButton( relative_rect=pg.Rect( center_x - button_width // 2, int(height * 0.35), button_width, button_height ), text="Play", manager=manager ) self.quit_button = pgi.elements.UIButton( relative_rect=pg.Rect( center_x - button_width // 2, int(height * 0.60), button_width, button_height ), text="Quit", manager=manager ) self.elements = [ self.title, self.play_button, self.quit_button ] def process_event(self, event): if event.type == pgi.UI_BUTTON_PRESSED: if event.ui_element == self.play_button: # Zum Gameplay wechseln self.game.change_screen("game") if event.ui_element == self.quit_button: pg.quit() exit()