Esempio n. 1
0
    def __init__(self,
                 screen,
                 bg_color=(0, 0, 0),
                 font=None,
                 font_size=35,
                 font_color=(255, 255, 255)):
        """set up all variables, prepare basic navigation"""
        self.screen = screen
        self.scr_width = self.screen.get_rect().width
        self.scr_height = self.screen.get_rect().height
        self.bg_color = bg_color
        self.clock = pygame.time.Clock()
        self.font = pygame.font.SysFont(font, font_size)
        self.font_color = font_color
        self.items = []
        self.funcs = OrderedDict()

        self.text_color = (255, 255, 255)

        self.funcs["Back"] = self.menu
        self.funcs["Quit"] = sys.exit
        items = self.funcs.keys()
        for index, item in enumerate(items):
            menu_item = MenuItem(item)
            t_h = len(items) * menu_item.height
            pos_x = (self.scr_width / 2) - (menu_item.width / 2)
            pos_y = (self.scr_height / 2) - (t_h / 2) + (
                (index * 2) + index * menu_item.height) + 120
            menu_item.set_position(pos_x, pos_y)
            self.items.append(menu_item)

        self.mouse_is_visible = True
        self.cur_item = None
        self.text_wall = TextWall()
        self.text_wall.parse_text(instruction_text)
Esempio n. 2
0
    def __init__(self,
                 screen,
                 bg_color=(0, 0, 0),
                 font=None,
                 font_size=35,
                 font_color=(255, 255, 255)):
        """Set up all variables, choose colors and fonts
        and preparing list of items in menu with functions
        which them called"""
        self.screen = screen
        self.scr_width = self.screen.get_rect().width
        self.scr_height = self.screen.get_rect().height
        self.bg_color = bg_color
        self.clock = pygame.time.Clock()
        self.font = pygame.font.SysFont(font, font_size)
        self.font_color = font_color
        self.items = []
        self.funcs = OrderedDict()
        self.funcs["Start Game"] = self.startgame
        self.funcs["Instruction"] = self.instruction
        self.funcs["Authors"] = self.showauthors
        self.funcs["Quit"] = sys.exit
        items = self.funcs.keys()
        for index, item in enumerate(items):
            menu_item = MenuItem(item)
            t_h = len(items) * menu_item.height
            pos_x = (self.scr_width / 2) - (menu_item.width / 2)
            pos_y = (self.scr_height / 2) - (t_h / 2) + (
                (index * 2) + index * menu_item.height)
            menu_item.set_position(pos_x, pos_y)
            self.items.append(menu_item)

        self.mouse_is_visible = True
        self.cur_item = None