def setup(self): red = (255, 0, 0) screen = pygame.display.get_surface() width = screen.get_width() height = screen.get_height() win_text = UIText('YOU DID IT!', 0, 0, 'win_text', 120, red) center_position = center_text(win_text, 0, 0, width, height) win_text.set_position(center_position) win_text.hide() self.add_element(win_text) move_count = UIText('Moves: 0', 10, 610, 'move_count', size=35) self.add_element(move_count)
def setup_menu(self): y = 0 heading_colour = Color('aquamarine') menu_group = UIGroup(0, 0, 'menu') heading = UIText('Path Finder', 0, 0, 'heading', 120, heading_colour) y += heading.get_height() + 20 start = UIText('Start', 0, y, 'start_btn', 80) y += start.get_height() + 20 help = UIText('Help', 0, y, 'help_btn', 80) y += help.get_height() + 20 exit = UIText('Exit', 0, y, 'exit_btn', 80) menu_group.add_element(heading) for element in [start, help, exit]: element.x = center_element_x(element, heading.get_width()).x menu_group.add_element(element) width = pygame.display.get_surface().get_width() menu_group.set_position(center_element_x(heading, width).x, 80) self.add_element(menu_group) help_group = UIGroup(0, 0, 'help_screen') y = 0 heading = UIText('Help', 0, 0, 'help_heading', 100, heading_colour) y += heading.get_height() + 20 texts = [ 'Connect all of the terminal pairs to finish the level.', 'R: Restart', 'Esc: Return to the main menu.', 'Right Click: Select and place terminal connectors.', 'Left Click: Cancel the current line\'s construction.', ] help_group.add_element(heading) for text in texts: instruction = UIText(text, 0, y, '', 30) y += instruction.get_height() + 5 help_group.add_element(instruction) help_group.set_position(50, 80) help_group.hide() self.add_element(help_group)