示例#1
0
    def draw_initial(self, game: Game):
        stdscr, pad = self.stdscr, self.pad

        def char(p, char, fgcolor):
            offset = Pt(1, 1)
            if game.in_bounds(p) and game.is_wrapped(p):
                bg_color = curses.COLOR_BLUE
            else:
                bg_color = curses.COLOR_BLACK
            p = p + offset
            pad.addstr(self.height - p.y + 1, p.x * 2, char + ' ',
                       colormapping[fgcolor, bg_color])

        #borders
        #for some reason the left border is not shown
        for x in range(game.width + 2):
            char(Pt(x - 1, -1), 'H', FgColors.Dungeon)
            char(Pt(x - 1, game.height), 'H', FgColors.Dungeon)
        for y in range(game.height + 2):
            char(Pt(-1, y - 1), 'H', FgColors.Dungeon)
            char(Pt(game.width, y - 1), 'H', FgColors.Dungeon)

        for p, c in game.enumerate_grid():
            char(p, c, FgColors.Dungeon)