コード例 #1
0
ファイル: screen.py プロジェクト: whitegreyblack/ecs
 def render(self):
     self.terminal.erase()
     border(self.terminal, 0, 0, self.engine.width - 1,
            self.engine.height - 1)
     self.terminal.addstr(0, 1, '[logs]')
     self.render_items()
     self.terminal.refresh()
コード例 #2
0
ファイル: screen.py プロジェクト: whitegreyblack/ecs
    def render(self):
        x = self.engine.width // 2
        y = self.engine.height // 2
        string = "you died"

        self.terminal.erase()
        border(self.terminal, 0, 0, self.engine.width - 1,
               self.engine.height - 1)
        self.terminal.addstr(0, 1, '[death screen]')
        self.terminal.addstr(y, x - len(string) // 2, string)
        self.terminal.refresh()
コード例 #3
0
    def render_logs_panel(self):
        border(self.terminal, self.logs_panel_x, self.logs_panel_y,
               self.logs_panel_width - 1, self.logs_panel_height)
        self.terminal.addstr(self.logs_panel_y, self.logs_panel_x + 1, '[log]')

        # logs = filter(lambda x: x.lifetime > 0, self.engine.logger.messages)
        logs = self.engine.logger.messages
        tilemap = self.engine.tilemaps.find(eid=self.engine.world.id)
        # only iterate slice of logs if it is larger than screen
        if len(logs) >= self.logs_items_height:
            l = max(0, len(logs) - self.logs_items_height - 1)
            logs = logs[l:]
        for y, log in enumerate(logs):
            log_y = self.logs_item_y + y
            self.render_log(log, log_y, self.logs_item_x)
コード例 #4
0
    def render_inventory_panel(self):
        border(self.terminal, self.inventory_x, self.inventory_y,
               self.inventory_width, self.inventory_height)
        self.terminal.addstr(1, 2, '[equipment]')

        inventory = self.engine.inventories.find(self.engine.player)
        # self.terminal.addstr(1, 1, f"{inventory}")
        if not inventory.items:
            self.terminal.addstr(2, 2, 'empty')
        else:
            items = []
            for eid, (_, info) in join(self.engine.items, self.engine.infos):
                if eid in inventory.items:
                    items.append(info)
            for i, info in enumerate(items):
                self.render_string(self.inventory_x + 1,
                                   self.inventory_y + 1 + i,
                                   f"{i+1}. {info.name}")
コード例 #5
0
ファイル: screen.py プロジェクト: whitegreyblack/ecs
 def render(self):
     self.terminal.erase()
     border(self.terminal, 0, 0, self.engine.width - 1,
            self.engine.height - 1)
     self.terminal.addstr(0, 1, '[equipment]')
     # get player equipment info
     e = self.engine.equipments.find(self.engine.player)
     head = None
     self.terminal.addstr(1, 1, f"HEAD: {head}")
     body = None
     self.terminal.addstr(2, 1, f"BODY: {body}")
     hand = None
     if e.hand:
         hand = self.engine.infos.find(eid=e.hand).name
     self.terminal.addstr(3, 1, f"HAND: {hand}")
     feet = None
     self.terminal.addstr(4, 1, f"FEET: {feet}")
     self.terminal.refresh()
コード例 #6
0
 def render_map(self, map_id, cam_x, cam_y, x0, x1, y0, y1):
     border(self.terminal, self.map_panel_x, self.map_panel_y,
            self.map_panel_width, self.map_panel_height)
     tiles = join(self.engine.visibilities, self.engine.positions,
                  self.engine.renders, self.engine.infos)
     for _, (visibility, position, render, info) in tiles:
         current_map_id = position.map_id == map_id
         visible = visibility.level > 0
         xbounds = x0 <= position.x < x1
         ybounds = y0 <= position.y < y1
         inbounds = xbounds and ybounds
         if current_map_id and visible and inbounds:
             if visibility.level == 2:
                 color = colors.get(info.name, 240)
             else:
                 color = 240
             self.render_char(position.x + self.map_x - cam_x,
                              position.y + self.map_y - cam_y, render.char,
                              curses.color_pair(color))
コード例 #7
0
ファイル: screen.py プロジェクト: whitegreyblack/ecs
    def render(self):
        x = self.engine.width // 2
        y = self.engine.height // 2

        option_y_offset = -1
        option_x_offset = -(max(map(len, self.options)) // 2)
        current_x_offset = -2

        self.terminal.erase()
        border(self.terminal, 0, 0, self.engine.width - 1,
               self.engine.height - 1)
        self.terminal.addstr(0, 1, '[main_menu]')
        for i, option in enumerate(self.options):
            current_option = i == self.index
            current_index_offset = 0
            if current_option:
                current_index_offset = current_x_offset
            self.terminal.addstr(y + option_y_offset + i,
                                 x + option_x_offset + current_index_offset,
                                 f"{'> ' if current_option else ''}{option}")
        self.terminal.refresh()
コード例 #8
0
 def render_player_panel(self):
     border(self.terminal, self.player_panel_x, self.player_panel_y,
            self.player_panel_width, self.player_panel_height)
     self.terminal.addstr(0, 1, '[info]')
コード例 #9
0
 def render_enemy_panel(self):
     """Initializes frame only. Content is filled by render_units"""
     border(self.terminal, self.enemy_panel_x, self.enemy_panel_y,
            self.enemy_panel_width, self.enemy_panel_height)
     self.render_string(self.enemy_panel_x + 1, self.enemy_panel_y,
                        '[enemies]')