def __init__(self, start_position, width, height, parent_frame=None):
        #images
        UIFrame.__init__(self, start_position, width, height, parent_frame)

        #elements
        self.create_button = TextButton(Vector2(0, height - 23),
                                        width,
                                        25,
                                        list(globals.button_img_list),
                                        "Create Game",
                                        self,
                                        self.create_pressed,
                                        text_pos=(29, 6))
        self.game_name_label = Label(Vector2(5, 0), "Room Name")
        self.game_name_text_field = TextField(
            Vector2(25, 15), width - 25, 15, "",
            list(globals.text_field_img_list), 10, self)
        self.cycle_button = CycleButton(
            Vector2(5, self.game_name_text_field.start_position.y + 30.0),
            width - 10, 15, globals.map_names, self)

        self.all_elements = [
            self.create_button, self.game_name_label, self.cycle_button,
            self.game_name_text_field
        ]
    def __init__(self, start_position, width, height, parent_frame):
        UIFrame.__init__(self, start_position, width, height, parent_frame)

        self.parent_frame = parent_frame

        #butons_frame
        self.buttons_frame = ButtonsFrame(Vector2(0, 60), width, height - 60,
                                          self, parent_frame)
        self.player_list_frame = PlayerListFrame(Vector2(0, 50), 250,
                                                 height - 100, self)

        self.all_elements = [self.buttons_frame, self.player_list_frame]
    def __init__(self, start_position, width, height, frame_parent):
        #images
        UIFrame.__init__(self, start_position, width, height, frame_parent)

        #room frame and nav buttons
        self.room_frame = PageButton(Vector2(170, 150), 600, 300, self)

        #create game and search game
        self.make_game_frame = MakeGameSurface(Vector2(0, 150),
                                               self.room_frame.rect.left - 10,
                                               self.room_frame.get_height(),
                                               self)

        self.all_elements = [self.room_frame, self.make_game_frame]
    def build_menu(self):
        """
        Blit text surface slices onto a bigger surface to build the menu.
        """

        #first account for whether the screen has changed size
        self.align_text()
        for current_index, menu_item in enumerate(
                self.current_sub_menu.menu_item_list):
            # Selected item is white. Others are off grey with blue tint.
            text_color = WHITE if current_index == self.selected_option else OFF_GREY_BLUE_TINT
            temporary_slice = self.font.render(menu_item.text, True,
                                               text_color)

            # Turn temporary_slice surface into WorldObject and add it to menu_item_list[current_index].
            if self.current_sub_menu.does_scroll:
                y_offset = (temporary_slice.get_height() + self.menu_negative_space) * \
                           (current_index - self.selected_option)
            else:
                y_offset = (temporary_slice.get_height() +
                            self.menu_negative_space) * current_index
            start_position = Vector2(self.text_position_x,
                                     self.text_position_y + y_offset)
            new_world_object = WorldObject(start_position,
                                           temporary_slice.get_width(),
                                           temporary_slice.get_height(), 0,
                                           [temporary_slice])
            self.current_sub_menu.menu_item_list[
                current_index].text_surface_slice = new_world_object

            # Blit each stripe onto pause_surface.
            self.pause_surface.blit(
                self.current_sub_menu.menu_item_list[current_index].
                text_surface_slice.image,
                (self.text_position_x, self.text_position_y + y_offset))
    def __init__(self, start_position, width, height, parent_frame):
        UIFrame.__init__(self, start_position, width, height, parent_frame)

        self.buttons_per_page = height / BUTTON_HEIGHT
        self.current_page = 0
        self.start_position = start_position
        self.back_button = Button(Vector2(0, 0), 50, height,
                                  list(globals.forward_button_img_list), self,
                                  self.back_pressed)
        self.forward_button = Button(Vector2(width - 50, 0), 50, height,
                                     list(globals.back_button_img_list), self,
                                     self.forward_pressed)
        self.game_button_list = []

        #begin polling for rooms
        self.update_game_list_thread = RepeatTask(5, self.update_game_list)
        self.update_game_list_thread.start()
    def update_game_list(self):

        temp_game_button_list = self.game_button_list
        self.game_button_list = []

        game_name_list = list_available_games(remote_server_name,
                                              remote_server_port)

        ix = 0
        for button in temp_game_button_list:
            if button.text in game_name_list:
                if ix == 0 or ix % self.buttons_per_page == 0:
                    button.start_position = Vector2(
                        self.back_button.rect.right, 0)
                    self.game_button_list.append(button)
                else:
                    button.start_position = Vector2(
                        self.game_button_list[-1].start_position.x,
                        self.game_button_list[-1].start_position.y +
                        self.game_button_list[-1].get_height())
                    self.game_button_list.append(button)

                game_name_list.remove(button.text)
            ix += 1

        for new_game_name in game_name_list:
            if ix == 0 or ix % self.buttons_per_page == 0:
                self.game_button_list.append(
                    TextButton(Vector2(self.back_button.rect.right,
                                       0), BUTTON_WIDTH, BUTTON_HEIGHT,
                               list(globals.join_game_img_list), new_game_name,
                               self, self.enter_lobby, (40, 22)))
            else:
                self.game_button_list.append(
                    TextButton(
                        Vector2(
                            self.game_button_list[-1].start_position.x,
                            self.game_button_list[-1].start_position.y +
                            self.game_button_list[-1].get_height()),
                        BUTTON_WIDTH, BUTTON_HEIGHT,
                        list(globals.join_game_img_list), new_game_name, self,
                        self.enter_lobby, (40, 22)))
            ix += 1
    def __init__(self, parent, start_position=Vector2(0.0, 0.0)):
        self.width = globals.screen.get_width()
        self.height = globals.screen.get_height()
        self.font = pygame.font.SysFont('arial', 12)

        UIFrame.__init__(self, start_position, self.width, self.height, parent)
        #WorldObject.__init__(self, start_position, self.screen_size_x, self.screen_size_y, velocity, image_list)

        #self.pause_menu = PauseMenu(font, self.screen_size_x, self.screen_size_y, screen)

        # # Make a chat box.
        # self.chat_box = ChatBox(player_heads_up_display=self)

        # Load sprite sheets.
        self.health = 0
        self.max_health = 0
        crosshair_sheet = SpriteSheet("resources/images/Crosshair Sheet.png")
        sprite_sheet = SpriteSheet("resources/images/Sprite Sheet1.png")

        # Load crosshair.
        self.crosshair = BlitData(
            crosshair_sheet.imageAt(pygame.Rect(176, 158, 46, 48)))

        # load health bar info
        self.hp_overlay = BlitData(
            sprite_sheet.imageAt(pygame.Rect(652, 373, 290, 90)), (0, 0))
        self.hp_bar = BlitData(
            sprite_sheet.imageAt(pygame.Rect(722, 485, 213, 40)), (64, 22))
        self.mana_bar = BlitData(
            sprite_sheet.imageAt(pygame.Rect(722, 529, 146, 20)), (68, 65),
            (0, 0, 159, 20))

        # set colorkey so black pixels will be transparent
        # self.image.set_colorkey(BLACK)  # set black to transparent
        # self.image.fill(BLACK)

        # ammo and weapon data
        self.ammo_string = "send me text"
        self.weapon_string = "send me text"
        self.ammo_string_surface = self.font.render(self.ammo_string, True,
                                                    [255, 255, 255])
        self.weapon_string_surface = self.font.render(self.weapon_string, True,
                                                      [255, 255, 255])
        self.ammo_blit = BlitData(self.ammo_string_surface,
                                  (globals.screen.get_width() / 1.16,
                                   globals.screen.get_height() / 1.11))
        self.weapon_blit = BlitData(self.weapon_string_surface,
                                    (globals.screen.get_width() / 1.16,
                                     globals.screen.get_height() / 1.066))
        # order this list in which one you want blit first.  top picture = last in the list.
        #self.blit_list = [self.hp_overlay, self.hp_bar, self.ammo_blit, self.weapon_blit, self.crosshair]
        self.blit_list = [
            self.hp_overlay, self.hp_bar, self.mana_bar, self.ammo_blit,
            self.weapon_blit, self.crosshair
        ]
    def __init__(self,
                 font,
                 screen_size_x,
                 screen_size_y,
                 screen,
                 start_position=Vector2(0.0, 0.0),
                 velocity=0):
        self.pause_surface = pygame.image.load('resources/images/jimi.png')
        self.pause_surface = pygame.transform.scale(
            self.pause_surface, (screen_size_x, screen_size_y))
        self.image = self.pause_surface
        image_list = [self.pause_surface]
        WorldObject.__init__(self, start_position, screen_size_x,
                             screen_size_y, velocity, image_list)

        self.screen = screen
        self.selected_option = 0
        self.font = font
        self.is_paused = False

        #Instantiate menus
        self.main_pause_menu = SubMenu(0, False)
        self.options_menu = SubMenu(1, False)
        self.resolution_options = SubMenu(2, True)

        # Populate menus and attach an action.
        # If you make a new menu option, be sure to add its function to the PauseMenu class.
        self.main_pause_menu.menu_item_list.extend(
            (MenuItem(self.resume, "Resume"),
             MenuItem(self.switch_to_options_menu,
                      "Options"), MenuItem(self.quit, "Quit")))
        self.options_menu.menu_item_list.extend(
            (MenuItem(self.switch_to_resolution_menu,
                      "Screen Resolution"), MenuItem(self.back, "Back")))
        self.resolution_options.menu_item_list.extend(
            self.generate_resolution_options())

        # This gets set to main_pause_menu when the game gets paused.
        self.current_sub_menu = self.main_pause_menu

        # Calculate start position for first menu item.
        self.x_displacement = 3.8
        self.y_displacement = 12.8
        self.text_position_x = (screen_size_x / 2) - (screen_size_x /
                                                      self.x_displacement)
        self.text_position_y = (screen_size_y / 2) - (screen_size_y /
                                                      self.y_displacement)
        self.pause_surface = pygame.Surface((screen_size_x, screen_size_y))

        self.menu_negative_space = screen_size_y / 24  # space between options

        self.update()

        self.return_to_main_menu = False
    def __init__(self):
        self.screen = pygame.display.set_mode((800, 600), DOUBLEBUF)
        screen_width, screen_height = self.screen.get_size()
        self.scene = None
        self.input = {}

        # Build frames.
        self.rooms_frame = RoomsFrame(Vector2(0, 20), screen_width,
                                      screen_height - 20 - 100, self)
        self.equipment_frame = EquipmentFrame(Vector2(0, 20), screen_width,
                                              screen_height - 20 - 100, self)
        names_frames = OrderedDict([('Rooms', self.rooms_frame),
                                    ('Equipment', self.equipment_frame)])
        self.tab_frame = TabFrame(Vector2(0, 0), 223, 20, names_frames, self)

        self.all_frames = [
            self.tab_frame, self.rooms_frame, self.equipment_frame
        ]

        # Configuration
        globals.online_game = join_game(reserved_games['join_game_lobby'],
                                        remote_server_name, remote_server_port,
                                        user_name)

        # Init chat box.
        self.chat_box = ChatBox(
            always_visible=True,
            box_width=self.screen.get_width(),
            x_offset=20,
            y_offset=0,
            box_height=100,
            max_chars=100,
            screen=self.screen)  # draws itself/loads it's own image

        self.menu_title_font = pygame.font.Font("resources/fonts/Zebulon.ttf",
                                                30)
        self.logo = pygame.image.load('resources/images/white_logo.gif')
        self.logo_title_surfaces = [
            self.menu_title_font.render("Space", True, OFF_WHITE),
            self.menu_title_font.render("Snakes", True, OFF_WHITE)
        ]
    def __init__(self, start_position, width, height, parent_frame,
                 game_lobby):
        UIFrame.__init__(self, start_position, width, height, parent_frame)
        #buttons
        self.ready_button = TextButton(
            Vector2(0, 0),
            157,
            38,
            list(globals.ready_button_img_list),
            "",
            self,
            function=PlayerNetworking().set_player_ready_status)
        self.start_game_button = TextButton(Vector2(160, 0),
                                            145,
                                            23,
                                            list(globals.button_img_list),
                                            "Start Game",
                                            self,
                                            game_lobby.start_game_pressed,
                                            text_pos=(25, 6))

        self.all_elements = [self.ready_button, self.start_game_button]
    def update_player_list(self, height_for_player_name=30):
        """
        Updates players in the lobby from the server.
        """

        if hasattr(globals, 'online_game') and globals.online_game is not None:
            players = globals.online_game.get_players()
            temp_elements = []
            for offset, player in enumerate(players):
                location = (self.list_padding,
                            ((height_for_player_name * offset + 1) +
                             self.list_padding / 2) + self.start_position[1])
                temp_elements.append(
                    Label(Vector2(location[0], location[1]),
                          player.user_name,
                          font_size=14))
                temp_elements.append(
                    ReadyStatusIndicator(
                        Vector2(location[0] - 20, location[1]), player.ready))

            self.all_elements = list(
                temp_elements
            )  # make a copy. this prevents flicker as the list populates.
    def __init__(self, game_name):
        self.input = {}
        self.scene = None
        self.background_surface = pygame.image.load(
            'resources/images/game_lobby_background_blue.png')
        self.game_name = game_name
        self.screen = pygame.display.set_mode((800, 600), DOUBLEBUF)
        self.chat_box = ChatBox(
            always_visible=True,
            box_width=self.screen.get_width(),
            x_offset=20,
            y_offset=0,
            box_height=100,
            max_chars=100,
            screen=self.screen)  # draws itself/loads it's own image

        # Set screen size.
        screen_width, screen_height = self.screen.get_size()

        #lobby_frame
        self.lobby_frame = LobbyFrame(Vector2(0, 20), screen_width,
                                      screen_height - 20 - 100, self)
        #equipment frame
        self.equipment_frame = EquipmentFrame(euclid.Vector2(0,
                                                             20), screen_width,
                                              screen_height - 20 - 100, self)
        #tab frame
        names_frames = OrderedDict([('Lobby', self.lobby_frame),
                                    ('Equipment', self.equipment_frame)])
        self.tab_frame = TabFrame(euclid.Vector2(0, 0), 223, 20, names_frames,
                                  self)

        self.all_frames = [
            self.tab_frame, self.lobby_frame, self.equipment_frame
        ]

        self.menu_title_font = pygame.font.Font("resources/fonts/Zebulon.ttf",
                                                30)
        self.logo = pygame.image.load('resources/images/white_logo.gif')
        self.logo_title_surfaces = [
            self.menu_title_font.render("Space", True, OFF_WHITE),
            self.menu_title_font.render("Snakes", True, OFF_WHITE)
        ]

        pygame.mouse.set_visible(True)