예제 #1
0
    def render(self, console: Console, context: Context) -> None:
        #render the map first
        self.game_map.render(console)

        context.present(console)

        console.clear()
예제 #2
0
파일: engine.py 프로젝트: aaoi990/hero-egg
    def render(self, console: Console, context: Context) -> None:
        self.game_map.render(console)

        render_menu(console=console,
                    map_height=self.game_map.height,
                    menu_width=100)

        self.message_log.render(console=console)

        # If the current event handler is the Inventory handler, show the inventory screen.
        if isinstance(self.event_handler, InventoryEventHandler):
            render_inventory_menu(console=console, engine=self)

        render_bar(console=console,
                   character=self.player,
                   current_value=self.player.fighter.hp,
                   maximum_value=self.player.fighter.max_hp,
                   total_width=20)

        render_names_at_mouse_location(console=console,
                                       x=21,
                                       y=44,
                                       engine=self)

        context.present(console)

        console.clear()
예제 #3
0
    def render(self, console: Console, context: Context) -> None:
        for entity in self.entities:
            console.print(entity.x, entity.y, entity.char, fg=entity.color)

        context.present(console)

        console.clear()
예제 #4
0
    def render(self, console: Console, context: Context):
        self.game_map.render(console)

        for entity in self.entities:
            if self.game_map.visible[entity.x, entity.y]:
                console.print(entity.x, entity.y, entity.char, fg=entity.color)

        context.present(console)
        console.clear()
예제 #5
0
    def render(self, console: Console, context: Context) -> None:
        """Method for rendering objects in TCOD terminal"""
        self.g_map.render(console)

        console.print(x=1, y=47,
                        string=f"HP: {self.player.stats.hp}/{self.player.stats.max_hp}")

        context.present(console)

        console.clear()
예제 #6
0
    def render(self, console: Console, context: Context) -> None:
        self.game_map.render(console)
        for entity in self.entities:
            # Only print entities that are in the FOV
            if self.game_map.visible[entity.x, entity.y]:
                console.print(entity.x, entity.y, entity.char, fg=entity.color)

        context.present(console)

        console.clear()
예제 #7
0
    def render(self, console: Console, context: Context) -> None:
        """The render function renders the tcod console and tcod context for us.
        by doing this it can display all the entities and respond to actions for us.
        The rendering function is run each game loop to update what is displayed to the user
        """
        # Shall call the game renderer object to render the different elements of the game, including the game map, the entities and the console.
        
        self.game_map.render_map(console)

        context.present(console)
        console.clear()
예제 #8
0
    def render(self, console: Console, context: Context) -> None:
        self.game_map.render(console)

        console.print(
            x=1,
            y=47,
            string=f"HP: {self.player.fighter.hp}/{self.player.fighter.max_hp}",
        )

        context.present(console)

        console.clear()
예제 #9
0
    def render(self, console: Console, context: Context) -> None:
        self.game_map.progress_redraw_all_transition()
        self.game_map.render(console, self.time_of_day)

        for entity in self.intelligent_entities:
            if self.game_map.tiles[entity.y][
                    entity.x].explored or not self.settings["show-fog"]:
                if entity.name in maps.entity_overview_map:
                    if not self.settings["entity-visibility"][
                            maps.entity_overview_map[entity.name]]:
                        continue

                if (isinstance(entity, rbt.Rabbit) and entity.asleep):
                    continue

                console.print(entity.x,
                              entity.y,
                              entity.char,
                              fg=entity.color,
                              bg=entity.bg_color)

        if self.selected_entity != None:
            entity = self.selected_entity

            if not isinstance(entity, rbt.Burrow) and not isinstance(
                    entity, bb.BerryBush) and not isinstance(entity, cp.Camp):
                render_selected = True

                if entity.name in maps.entity_overview_map:
                    render_selected = self.settings["entity-visibility"][
                        maps.entity_overview_map[entity.name]]

                if render_selected:
                    console.print(entity.x,
                                  entity.y,
                                  entity.char,
                                  fg=entity.color,
                                  bg=entity.bg_color)

        if self.settings["show-ui"]:
            self.stats_panel.render(console)
            self.hover_panel.render(console)
            self.selection_panel.render(console)
            self.action_log_panel.render(console)
            self.game_menu_panel.render(console)
            self.controls_panel.render(console)

            if self.settings["show-entity-overview"]:
                self.entity_overview_panel.render(console)

        context.present(console)
예제 #10
0
    def render(self, console: tConsole, context: Context) -> None:
        self.__mockup_render(console)
        self.screen.render_main(console, self.player_ship, 1, 1,
                                SCREEN_WIDTH - SIDEBAR_WIDTH - 1,
                                SCREEN_HEIGHT - CONSOLE_HEIGHT - 2)
        self.sidebar.render(console, SCREEN_WIDTH - SIDEBAR_WIDTH + 1, 1,
                            SIDEBAR_WIDTH - 2, SCREEN_HEIGHT - 8)
        self.console.render(console, 1, SCREEN_HEIGHT - CONSOLE_HEIGHT,
                            CONSOLE_HEIGHT - 2,
                            SCREEN_WIDTH - SIDEBAR_WIDTH - 1)
        self.render_frames(console)

        context.present(console)
        console.clear()
예제 #11
0
    def render(self, console: Console, context: Context) -> None:
        ''' 
        GameMap instance renders independently using its own .render() method. 
        Then 'tcod.context' displays the console to the screen. 
        '''
        self.game_map.render(console)

        console.print(
            x=1,
            y=47,
            string=
            f"HP: {self.player.fighter.hp} / {self.player.fighter.max_hp}")

        context.present(console)
        console.clear()
예제 #12
0
    def render(self, console: Console, context: Context) -> None:
        """
        The display portion of the game loop, now as its own method.

        :param console:
        :param context:
        :return: None
        """
        # draw the game map on screen
        self.game_map.render(console)
        # loop through all the entities
        for entity in self.entities:
            # and place them on the console
            console.print(entity.x, entity.y, entity.char, entity.color)
        # update the screen so we can see them
        context.present(console)
        # clear console to prevent 'trailing'
        console.clear()
예제 #13
0
    def handle_events(self, context: Context) -> None:
        from death_functions import check_for_dead_entities

        for event in tcod.event.wait():
            context.convert_event(event)

            action = self.dispatch(event)

            if action is None:
                continue

            turn_passed = action.perform()

            check_for_dead_entities(self.engine)

            if turn_passed:
                self.engine.handle_enemy_turns()

            # Update the FOV before the players next action.
            self.engine.update_fov()