def menuLoop(window): pygame.display.set_caption("Chess menu") selectedLayout = BoardLayout(pygame.Color("white"), pygame.Color("gray"), 160, 30, pygame.Color("blue"), pygame.Color("yellow")) selectedTableImage = TableImage(140, 300, 100, 100, "1") selectedTimer = Button(150, 50, 125, 425, "Unlimited", pygame.Color("yellow"), 32) selectedTimerMinutes = getSelectedTimerMinutes(selectedTimer) undo = False backgroundImage = pygame.transform.scale( pygame.image.load("images/menu/background.jpg").convert(), (width, height)) run = True playButton = Button(200, 100, width // 2 - 50, height // 3 + 50, "Play", pygame.Color("red"), 48) optionsButton = Button(200, 100, width // 2 - 85, height // 3 + 150, "Options", pygame.Color("red"), 48) quitButton = Button(200, 100, width // 2 - 50, height // 3 + 250, "Quit", pygame.Color("red"), 48) playButtonInitialSize = playButton.getTextSize() buttonInitialSize = optionsButton.getTextSize() while run: window.blit(backgroundImage, (0, 0)) displayText(window, "CHESS", 180, 50, 100, pygame.Color("green")) playButton.displayButton(window) optionsButton.displayButton(window) quitButton.displayButton(window) position = pygame.mouse.get_pos() for e in pygame.event.get(): if e.type == pygame.QUIT: run = False elif e.type == pygame.MOUSEBUTTONDOWN: if playButton.mouseOverButton(position): gameLoop(window, selectedLayout, undo, selectedTableImage, selectedTimerMinutes) elif optionsButton.mouseOverButton(position): selectedLayout, undo, selectedTableImage, selectedTimer = optionsLoop( window, backgroundImage) selectedTimerMinutes = getSelectedTimerMinutes( selectedTimer) elif quitButton.mouseOverButton(position): run = False elif e.type == pygame.MOUSEMOTION: playButton.animateButton(position, playButtonInitialSize) optionsButton.animateButton(position, buttonInitialSize) quitButton.animateButton(position, buttonInitialSize) pygame.display.flip()