Ejemplo n.º 1
0
    def startup(self, **kwargs):
        super(MonsterMenuState, self).startup(**kwargs)

        # make a text area to show messages
        self.text_area = TextArea(self.font, self.font_color, (96, 96, 96))
        self.text_area.rect = pygame.Rect(
            tools.scale_sequence([20, 80, 80, 100]))
        self.sprites.add(self.text_area, layer=100)

        # Set up the border images used for the monster slots
        self.monster_slot_border = {}
        self.monster_portrait = pygame.sprite.Sprite()
        self.hp_bar = HpBar()

        # load and scale the monster slot borders
        root = "gfx/ui/monster/"
        border_types = ["empty", "filled", "active"]
        for border_type in border_types:
            filename = root + border_type + "_monster_slot_border.png"
            border = tools.load_and_scale(filename)

            filename = root + border_type + "_monster_slot_bg.png"
            background = tools.load_image(filename)

            window = GraphicBox(border, background, None)
            self.monster_slot_border[border_type] = window

        # TODO: something better than this global, load_sprites stuff
        for monster in self.game.player1.monsters:
            monster.load_sprites()
Ejemplo n.º 2
0
    def startup(self, *args, **kwargs):
        super(CombatTargetMenuState, self).startup(*args, **kwargs)

        # used to determine how player can target techniques
        self.user = kwargs.get("user")
        self.action = kwargs.get("action")
        self.player = kwargs.get("player")

        # load and scale the menu borders
        border = tools.load_and_scale(self.borders_filename)
        self.border = GraphicBox(border, None, None)
Ejemplo n.º 3
0
    def show_combat_dialog(self):
        """ Create and show the area where battle messages are displayed
        """
        # make the border and area at the bottom of the screen for messages
        x, y, w, h = self.game.screen.get_rect()
        rect = pygame.Rect(0, 0, w, h // 4)
        rect.bottomright = w, h
        border = tools.load_and_scale(self.borders_filename)
        self.dialog_box = GraphicBox(border, None, self.background_color)
        self.dialog_box.rect = rect
        self.sprites.add(self.dialog_box, layer=100)

        # make a text area to show messages
        self.text_area = TextArea(self.font, self.font_color)
        self.text_area.rect = self.dialog_box.calc_inner_rect(self.dialog_box.rect)
        self.sprites.add(self.text_area, layer=100)
Ejemplo n.º 4
0
    def load_graphics(self):
        """ Loads all the graphical elements of the menu
            Will load some elements from disk, so needs to be called at least once.
        """
        # load and scale the _background
        background = None
        if self.background_filename:
            background = tools.load_image(self.background_filename)

        # load and scale the menu borders
        border = None
        if self.draw_borders:
            border = tools.load_and_scale(self.borders_filename)

        # set the helper to draw the _background
        self.window = GraphicBox(border, background, self.background_color)

        # handle the arrow cursor
        image = tools.load_and_scale(self.cursor_filename)
        self.arrow = MenuCursor(image)
Ejemplo n.º 5
0
 def load_graphics(self):
     """ Image become class attribute, so is shared.
         Eventually, implement some game-wide image caching
     """
     image = tools.load_and_scale(self.border_filename)
     HpBar.border = GraphicBox(image)