Exemplo n.º 1
0
    def __init__(self, console_height, console_width):
        """Create a main screen.

        :param console_height: the height of the console
        :param console_width: the width of the console
        :return: null
        """
        # List should be two smaller in each direction because of surrounding border.
        self._dungeon_height, self._dungeon_width = console_height-2, console_width-2

        # Center the window based on the size of the console.
        display_start_y, display_start_x = util.center_start(console_height, console_width,
                                                             self._dungeon_height, self._dungeon_width)

        # Initialize a Dungeon to serve as a main dungeon.
        self._dungeon = Dungeon(self._dungeon_width, self._dungeon_height)

        # Create window that will act as main visual.
        self._dungeon_display = curses.newwin(self._dungeon_height, self._dungeon_width, display_start_y, display_start_x)

        # Add visual detail to window.
        self._dungeon_display.bkgd(' ', curses.color_pair(1))
        util.color_box(self._dungeon_display, 0, 0, self._dungeon_height-1, self._dungeon_width-1, 3)

        # Initializes help window for use in pause().
        help_height, help_width = 12, 50
        help_y, help_x = util.center_start(console_height, console_width, help_height, help_width)
        self.help_window = curses.newwin(help_height, help_width, help_y, help_x)
Exemplo n.º 2
0
    def clear_screen(self):
        """Clear the contents of the screen.

        :return: a reference to the main screen
        """
        self._dungeon_display.clear()

        # Add back border and show display
        util.color_box(self._dungeon_display, 0, 0, self._dungeon_height-1, self._dungeon_width-1, 3)
        self._dungeon_display.refresh()

        return self