def start_settings(self): """ This is the settings menu that controls the user actions """ screen_title = Text(self.screen) back = SquareButton(self.screen, 100, 200, 150, 50, WHITE, LIGHT_GREY, text_button_back) running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() if event.type == pygame.MOUSEBUTTONDOWN: if back.is_hover(): # Quit settings running = False self.screen.fill(WHITE) screen_title.draw_text_raw(text_button_settings, 540, 100, 50) back.draw_button() pygame.display.update()
def yes_no_popup(self, custom_text): running = True dialog = Text(self.screen) yes_button = SquareButton(self.screen, 440, 300, 100, 75, WHITE, LIGHT_GREY, "Yes") while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.draw.rect(self.screen, WHITE, (365, 285, 350, 150)) dialog.draw_text_raw(custom_text, 200, 250) yes_button.draw_button() pygame.display.flip()
def yes_no_popup(self, custom_text): # TODO: Fix this """ Makes a popup window that displays a yes or no questions (would you like to quit?) """ running = True dialog = Text(self.screen) yes_button = SquareButton(self.screen, 440, 300, 100, 75, WHITE, LIGHT_GREY, "Yes") while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.draw.rect(self.screen, WHITE, (365, 285, 350, 150)) dialog.draw_text_raw(custom_text, 200, 250) yes_button.draw_button() pygame.display.flip()
def start_menu(self): global BACKGROUND running = True clock = pygame.time.Clock() start_button = SquareButton(self.screen, 100, 200, 150, 50, WHITE, LIGHT_GREY, text_button_start) multiplayer_button = SquareButton(self.screen, 100, 300, 150, 50, WHITE, LIGHT_GREY, text_button_multiplayer) settings_button = SquareButton(self.screen, 100, 400, 150, 50, WHITE, LIGHT_GREY, text_button_settings) quit_button = SquareButton(self.screen, 100, 500, 150, 50, WHITE, LIGHT_GREY, text_button_exit) game_title_object = Text(self.screen) color1 = [111, 168, 0] color2 = [215, 255, 137] while running: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() if event.type == pygame.MOUSEBUTTONDOWN: if quit_button.is_hover(): # Quit menu pygame.quit() quit() if start_button.is_hover(): # Start game running = False if settings_button.is_hover(): #Settings(self.screen) pass BACKGROUND = self.background_color(color1, color2) self.screen.fill(BACKGROUND) game_title_object.draw_text_raw(text_game_title, 540, 100, 50) start_button.draw_button() multiplayer_button.draw_button() settings_button.draw_button() quit_button.draw_button() clock.tick(60) pygame.display.flip()
def pause_menu(self): running = True unpause_button = SquareButton(self.screen, 100, 200, 150, 50, WHITE, LIGHT_GREY, text_button_stop_pause) settings_button = SquareButton(self.screen, 100, 300, 150, 50, WHITE, LIGHT_GREY, text_button_settings) back_to_menu = SquareButton(self.screen, 100, 400, 150, 50, WHITE, LIGHT_GREY, text_button_back_to_menu) quit_button = SquareButton(self.screen, 100, 500, 150, 50, WHITE, LIGHT_GREY, text_button_exit) quit_popup = Popup(self.screen) while running: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() if event.type == pygame.MOUSEBUTTONDOWN: if unpause_button.is_hover(): running = False if settings_button.is_hover(): Settings(self.screen) if back_to_menu.is_hover(): Menu(self.screen) if quit_button.is_hover(): quit_popup.yes_no_popup( "Are you sure you want to quit?") pygame.quit() quit() unpause_button.draw_button() settings_button.draw_button() back_to_menu.draw_button() quit_button.draw_button() pygame.display.flip()
def pause_menu(self): """ This is the pause menu that controls the user actions """ running = True screen_title = Text(self.screen) unpause_button = SquareButton(self.screen, 100, 200, 150, 50, WHITE, LIGHT_GREY, text_button_stop_pause) settings_button = SquareButton(self.screen, 100, 300, 150, 50, WHITE, LIGHT_GREY, text_button_settings) back_to_menu = SquareButton(self.screen, 100, 400, 150, 50, WHITE, LIGHT_GREY, text_button_back_to_menu) quit_button = SquareButton(self.screen, 100, 500, 150, 50, WHITE, LIGHT_GREY, text_button_exit) while running: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: running = False if event.type == pygame.MOUSEBUTTONDOWN: if unpause_button.is_hover(): running = False if settings_button.is_hover(): Settings(self.screen) if back_to_menu.is_hover(): Menu(self.screen) if quit_button.is_hover(): pygame.quit() quit() screen_title.draw_text_raw(text_game_paused, 540, 100, 50, font_color=WHITE) unpause_button.draw_button() settings_button.draw_button() back_to_menu.draw_button() quit_button.draw_button() pygame.display.update()