def render_messages(cls, console: tcod.Console, x: int, y: int, width: int, height: int, messages: Reversible[Message], ) -> None: """Render the messages provided. The `messages` are rendered starting at the last message and working backwards. """ console.draw_frame( x=x, y=y, width=width, height=height, title="Ship Log", ) width-=2 height-=2 y_offset = height - 1 for message in reversed(messages): for line in reversed(list(cls.wrap(message.full_text, width))): console.print(x=x+1, y=y + y_offset+1, string=line, fg=message.fg) y_offset -= 1 if y_offset < 0: return # No more space to print messages.
def render(self, console): if self.time_alive > self.lifespan: self.stop() if (self.direction == VerticalWipeDirection.DOWN): self.current_wipe_height += self.speed * self.engine.get_delta_time( ) elif (self.direction == VerticalWipeDirection.UP): self.current_wipe_height -= self.speed * self.engine.get_delta_time( ) temp_console = Console(width=self.width, height=self.height, order="F") for x in range(0, self.width): for y in range(0, self.height): temp_console.tiles_rgb[x, y] = self.tiles[x, y] temp_console.blit(console, src_x=self.x, src_y=self.y, dest_x=0, dest_y=0 + int(self.current_wipe_height), width=self.width, height=self.height - int(self.current_wipe_height)) self.time_alive += 0.16
def on_render(self, console: tcod.Console) -> None: """Render an inventory menu, which displays the items in the inventory, and the letter to select them. Will move to a different position based on where the player is located, so the player can always see where they are. """ super().on_render(console) number_of_items_in_inventory = len(self.engine.player.inventory.items) height = 16 if height <= 3: height = 3 if self.engine.player.x <= 30: x = 20 else: x = 0 y = 0 width = len(self.TITLE) + 40 console.draw_frame( x=x, y=y, width=width, height=height, title=self.TITLE, clear=True, fg=(255, 255, 255), bg=(0, 0, 0), )
def on_render(self, console: tcod.Console) -> None: console.print( console.width // 2, console.height // 2 - 10, "HOW TO PLAY", fg=color.menu_title, alignment=tcod.CENTER, ) menu_width = console.width // 4 for i, text in enumerate([ "UP ARROW........move up", "\n", "DOWN ARROW......move down", "\n", "RIGHT ARROW.....move right", "\n", "LEFT ARROW......move left", "\n", "ESCAPE..........exit game", "\n", "KEY V...............open history", "\n", "KEY G...............pick up item", "\n", "KEY D...............drop item", "\n", "KEY I...............open inventory", "\n", "KEY C...............open character tab", "\n", "KEY L...............toggle look around", "\n", "KEY Y...............use stairs" ]): console.print( console.width // 2, console.height // 2 - 2 + i, text.ljust(menu_width), fg=color.menu_text, bg=color.black, alignment=tcod.CENTER, bg_blend=tcod.BKGND_ALPHA(64), )
def on_render(self, console: tcod.Console) -> None: """Highlight the tile under the cursor.""" super().on_render(console) x, y = self.engine.mouse_location x, y = self.engine.camera.apply(x, y) console.tiles_rgb["bg"][x, y] = color.white console.tiles_rgb["fg"][x, y] = color.black
def render_names_at_mouse_location(console: Console, x: int, y: int, engine: Engine) -> None: mouse_x, mouse_y = engine.mouse_location names_at_mouse_location = get_names_at_location(x=mouse_x, y=mouse_y, game_map=engine.game_map) console.print(x=x, y=y, string=names_at_mouse_location)
def render_messages( cls, console: tcod.Console, x: int, y: int, width: int, height: int, messages: Reversible[Message], ) -> None: """Render the messages provided Beskederne er renderet baglæns fra den sidste besked Args: console (tcod.Console): Consolen x (int): X-Koordinat y (int): Y-Koordinat width (int): Bredde height (int): højde messages (Reversible[Message]): Listen af beskeder """ y_offset = height - 1 for message in reversed(messages): for line in reversed(list(cls.wrap(message.full_text, width))): console.print(x=x, y=y + y_offset, string=line, fg=message.fg) y_offset -= 1 if y_offset < 0: return # Ikke mere plads til at printe beskeden
def render(self, console): columns_finished = True for col in range(0, self.width): if self.time_alive > self.col_trigger_times[col]: self.current_wipe_heights[col] += self.height / self.lifespan if self.current_wipe_heights[col] < self.height: columns_finished = False temp_console = Console(width=1, height=self.height, order="F") for y in range(0, self.height): temp_console.tiles_rgb[0, y] = self.tiles[col, y] temp_console.blit(console, src_x=0, src_y=0, dest_x=col, dest_y=int(self.current_wipe_heights[col]), width=1, height=self.height - int(self.current_wipe_heights[col])) self.time_alive += 0.16 if columns_finished == True: self.stop()
def render_character_name( console: Console, x: int, y: int, character: Actor, ) -> None: console.print(x=x, y=y, string=f"{character.name}", fg=color.yellow)
def render(self, console: tcod.Console, *, x:int=0, y:int=0, fg:Optional[Tuple[int,int,int]]=None, bg:Optional[Tuple[int,int,int]]= None, text:Optional[str]=None, alignment:Optional[int]=None ): console.draw_frame( x=x+self.x, y=y+self.y, width=self.width, height=self.height, title=self.title, fg=fg if fg else self.fg, bg=bg if bg else self.bg, ) string_text = text if text is not None else self.text console.print_box( x=x+self.x+1, y=y+self.y+1, height=self.height-2, width=self.width-2, string=string_text, fg=fg if fg else self.fg, bg=bg if bg else self.bg, alignment=alignment if alignment is not None else self.alignment )
def render_dungeon_level( console: Console, dungeon_level: int, location: Tuple[int, int] ) -> None: """ Render the level the players current. """ x, y = location console.print(x=x, y=y, string=f"Dungeon level {dungeon_level}")
def render_menu(console: Console, map_height: int, menu_width: int) -> None: console.draw_frame(0, map_height, menu_width, 7, "MENU", True, fg=(255, 255, 255), bg=(0, 0, 0)) console.draw_frame(80, 0, 20, 43, "EVENTS", True, fg=(255, 255, 255), bg=(0, 0, 0))
def render_dungeon_level(console: Console, dungeon_level: int, location: Tuple[int, int]) -> None: ''' Render the level the player is currently on, at the given location. ''' x, y = location console.print(x=x, y=y, string=f'Dungeon level: {dungeon_level}')
def render_spaceship_level(console: Console, dungeon_level: int, location: Tuple[int, int]) -> None: """ Отображает на каком этаже персонаж. """ x, y = location console.print(x=x, y=y, string=f"Floor: {dungeon_level}")
def render_dungeon_level( console: Console, dungeon_level: int, location: Tuple[int, int] ) -> None: """ Renders any necessary level info for current level the player is on """ x, y = location console.print(x=x, y=y, string=f"Dungeon Level: {dungeon_level}")
def render_command_box(console: Console, gameData:GameData, title:str): console.draw_frame( x=CONFIG_OBJECT.command_display_x, y=CONFIG_OBJECT.command_display_y, width=CONFIG_OBJECT.command_display_end_x - CONFIG_OBJECT.command_display_x, height=CONFIG_OBJECT.command_display_end_y - CONFIG_OBJECT.command_display_y, title=title )
def render_dungeon_level( console: Console, dungeon_level: int, location: Tuple[int, int] ) -> None: """ Render the level the player is currently on, at the given location. """ x, y = location console.print(x=x, y=y, string=f"Castle level: {dungeon_level}")
def render(self, console: tcod.Console) -> None: y_offset: int = self.y for message in self.messages: console.print(x=self.x, y=y_offset, string=message.text, fg=message.color) y_offset += 1
def render_names_at_mouse_location(console: Console, x: int, y: int, engine: Engine) -> None: map_x, map_y = engine.game_map.viewport_to_map_coord(engine.mouse_location) names_at_mouse_location = get_names_at_location(x=map_x, y=map_y, game_map=engine.game_map) console.print(x=x, y=y, string=names_at_mouse_location)
def render_dungeon_level( console: Console, dungeon_level: int, location: Tuple[int, int] ) -> None: """ Render the current level's number to the given location """ x, y = location console.print(x=x, y=y, string=f"Dungeon level: {dungeon_level}")
def render_gameinfo( console: Console, x: int, y: int, depth: int, game_turn: int, ) -> None: """print dungeon depth, game turn, etc.""" console.print(x=x, y=y, string=f"Depth: {depth}", fg=color.white) console.print(x=x + 11, y=y, string=f"Turn: {game_turn}", fg=color.gray)
def render_messages(cls, console: tcod.Console, x: int, y: int, width: int, height: int, messages: Reversible[Message]) -> None: y_offset = height - 1 for message in reversed(messages): for line in reversed(list(cls.wrap(message.full_text, width))): console.print(x=x, y=y + y_offset, string=line, fg=message.fg) y_offset -= 1 if y_offset < 0: return
def on_render(self, console: tcod.Console) -> None: self.parent.on_render(console) console.tiles_rgb["fg"] //= 8 console.tiles_rgb["bg"] //= 8 console.print(console.width // 2, console.height // 2, self.text, fg=color.white, bg=color.black, alignment=tcod.CENTER)
def on_render(self, console: tcod.Console) -> None: super().on_render(console) x, y = self.engine.mouse_location console.draw_frame(x=x - self.radius - 1, y=y - self.radius - 1, width=self.radius**2, height=self.radius**2, fg=color.red, clear=False)
def render_names_at_mouse_location( console: Console, x: int, y: int, engine: Engine ) -> None: """Shows the name of entities on the pointed/chosen tile""" mouse_x, mouse_y = engine.mouse_location names_at_mouse_location = get_names_at_location( x=mouse_x, y=mouse_y, game_map=engine.game_map ) console.print(x=x, y=y, string=names_at_mouse_location)
def render_graphics_debug(console: Console, player: Entity, game_map: GameMap, location: Tuple[int, int]) -> None: x, y = location console.print(x=x, y=y, string=f"Player @: {player.x}, {player.y}") console.print( x=x, y=y + 1, string= f"VP anchor: {game_map.viewport_anchor_x}, {game_map.viewport_anchor_y}", )
def print_text_to_screen(self, console:tcod.Console, x:int, y:int, fg:Optional[Tuple[int,int,int]]=None, bg:Optional[Tuple[int,int,int]]=None) -> None: s = self.text_to_print if 0 < self.number_of_chars else " " try: s2 = s[self.cursor] except IndexError: s2 = " " console.print(x=x,y=y, string=s, fg=fg, bg=bg, bg_blend=constants.BKGND_SET) console.print(x=x+self.cursor, y=y, string=s2, fg=bg, bg=fg)
def highlight(console: tcod.Console, xy: Tuple[int, int], *, fg: Tuple[int, int, int] = color.black, bg: Tuple[int, int, int] = color.white) -> None: try: x, y = xy if x >= 0 and y >= 0: console.tiles_rgb["bg"][xy] = bg console.tiles_rgb["fg"][xy] = fg except IndexError: pass # Ignore to write out of index.
def render_messages(cls, console: tcod.Console, x: int, y: int, width: int, height: int, messages: Reversible[Message]) -> None: """Render the messages provided. The 'messages' are rendered starting at the last message and working backwards. """ y_offset = height - 1 for message in reversed(messages): for line in reversed(list(cls.wrap(message.full_text, width))): console.print(x=x, y=y + y_offset, string=line, fg=message.fg) y_offset -= 1 if y_offset < 0: return # No more space to print messages.
def on_render(self, console: tcod.Console) -> None: """Render the main menu on a background image.""" console.draw_semigraphics(background_image, 0, 0) console.print( console.width // 2, console.height // 2 - 4, "TOMBS OF THE ANCIENT KINGS", fg=color.menu_title, alignment=tcod.CENTER, ) console.print( console.width // 2, console.height - 2, "By (Your name here)", fg=color.menu_title, alignment=tcod.CENTER, ) menu_width = 24 for i, text in enumerate( ["[N] Play a new game", "[C] Continue last game", "[Q] Quit"]): console.print( console.width // 2, console.height // 2 - 2 + i, text.ljust(menu_width), fg=color.menu_text, bg=color.black, alignment=tcod.CENTER, bg_blend=tcod.BKGND_ALPHA(64), )