How to use the tcod.console_put_char_ex function in tcod

To help you get started, we’ve selected a few tcod examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Wolfenswan / RoguelikeTut-TCOD / rendering / util_functions.py View on Github external
def draw_console_borders(con, width=None, height=None, color=colors.dark_grey, bgcolor=colors.black):
    """ draws an outline around the passed console. By default, the console's width & height will be used """
    #tcod.console_set_default_foreground(con, color)

    if width is None:
        width = con.width
    if height is None:
        height = con.height

    for x in range(width):
        tcod.console_put_char_ex(con, x, 0, 196, color, bgcolor)
        tcod.console_put_char_ex(con, x, height - 1, 196, color, bgcolor)

    for y in range(height):
        tcod.console_put_char_ex(con, 0, y, 179, color, bgcolor)
        tcod.console_put_char_ex(con, width - 1, y, 179, color, bgcolor)

    tcod.console_put_char_ex(con, 0, 0, 218, color, bgcolor)
    tcod.console_put_char_ex(con, width - 1, 0, 191, color, bgcolor)
    tcod.console_put_char_ex(con, 0, height - 1, 192, color, bgcolor)
    tcod.console_put_char_ex(con, width - 1, height - 1, 217, color, bgcolor)
github eyeCube / Softly-Roguelike / tilemap.py View on Github external
def _discover_place(self, x,y,ent=None):
        world=rog.world()
##        ent = self.thingat(x,y)
        if ent and not world.has_component(ent, cmp.Creature):
            draw=world.component_for_entity(ent, cmp.Draw)
            libtcod.console_put_char_ex( # memorize items, not creatures
                self.con_memories, x,y, draw.char, COL['dkgray'],COL['black']
                )
        else:
            libtcod.console_put_char_ex(self.con_memories, x,y,
                                        self.get_char(x,y),
                                        COL['dkgray'], COL['black'])
github Wolfenswan / RoguelikeTut-TCOD / rendering / render_panels.py View on Github external
# initial offsets from panel borders
        y = 2

        for ent in spotted:  # Go through the object names and wrap them according to the panel's width
            if y >= con.height - 2:  # If the limit's of the con are reached, cut the con off
                tcod.console_set_default_foreground(con, colors.white)
                x = center_x_for_text(width, '~ ~ ~ MORE ~ ~ ~')
                print_string(con, x, y, '~ ~ ~ MORE ~ ~ ~')
                break

            char = '*' if ent.pos == game.cursor.pos and game.state in [GameState.CURSOR_ACTIVE, GameState.CURSOR_TARGETING] else f'{ent.char}'

            # Draw creature name and stats #
            tcod.console_set_default_foreground(con, colors.gray)
            tcod.console_set_color_control(tcod.COLCTRL_1, ent.color, tcod.black)
            tcod.console_put_char_ex(con, 1, y, char, ent.color, tcod.black)
            print_string(con, 3, y, ent.full_name, color = ent.color)
            y += 1
            x = 1
            tcod.console_put_char_ex(con, x, y, chr(192), tcod.gray, tcod.black)
            tcod.console_set_color_control(tcod.COLCTRL_2, ent.f.hp_color, tcod.black)
            tcod.console_set_color_control(tcod.COLCTRL_3, ent.f.stamina_color, tcod.black)
            status_line = f'%c{ent.f.hp_string.title()}%c|%c{ent.f.stamina_string.title()}%c'\
                          % (tcod.COLCTRL_2, tcod.COLCTRL_STOP, tcod.COLCTRL_3, tcod.COLCTRL_STOP)
            for status, active in ent.f.effects.items(): # Todo does not consider number of status effects > width of panel
                if active:
                    status_line += f' %white%{status.name[0]}%%'

            print_string(con, x+1, y, f'{status_line}')

            y += 1
github sudasana / armcom2 / xp_loader.py View on Github external
def load_layer_to_console(console, xp_file_layer):
	if not xp_file_layer['width'] or not xp_file_layer['height']:
		raise AttributeError('Attempted to call load_layer_to_console on data that didn\'t have a width or height key, check your data')

	for x in range(xp_file_layer['width']):
		for y in range(xp_file_layer['height']):
			cell_data = xp_file_layer['cells'][x][y]
			fore_color = libtcod.Color(cell_data['fore_r'], cell_data['fore_g'], cell_data['fore_b'])
			back_color = libtcod.Color(cell_data['back_r'], cell_data['back_g'], cell_data['back_b'])
			libtcod.console_put_char_ex(console, x, y, cell_data['keycode'], fore_color, back_color)
github eyeCube / Softly-Roguelike / tilemap.py View on Github external
def _discover_place(self, x,y,ent=None):
        world=rog.world()
##        ent = self.thingat(x,y)
        if ent and not world.has_component(ent, cmp.Creature):
            draw=world.component_for_entity(ent, cmp.Draw)
            libtcod.console_put_char_ex( # memorize items, not creatures
                self.con_memories, x,y, draw.char, COL['dkgray'],COL['black']
                )
        else:
            libtcod.console_put_char_ex(self.con_memories, x,y,
                                        self.get_char(x,y),
                                        COL['dkgray'], COL['black'])
github eyeCube / Softly-Roguelike / src / tilemap.py View on Github external
def _discover_place(self, x,y,char=None):
        world=rog.world()
##        ent = self.thingat(x,y)
        if char:
            libtcod.console_put_char_ex(
                self.con_memories, x,y, char, COL['dkgray'],COL['black']
                )
        else:
            libtcod.console_put_char_ex(self.con_memories, x,y,
                                        self.get_char(x,y),
                                        COL['dkgray'], COL['black'])
github Wolfenswan / RoguelikeTut-TCOD / rendering / util_functions.py View on Github external
#tcod.console_set_default_foreground(con, color)

    if width is None:
        width = con.width
    if height is None:
        height = con.height

    for x in range(width):
        tcod.console_put_char_ex(con, x, 0, 196, color, bgcolor)
        tcod.console_put_char_ex(con, x, height - 1, 196, color, bgcolor)

    for y in range(height):
        tcod.console_put_char_ex(con, 0, y, 179, color, bgcolor)
        tcod.console_put_char_ex(con, width - 1, y, 179, color, bgcolor)

    tcod.console_put_char_ex(con, 0, 0, 218, color, bgcolor)
    tcod.console_put_char_ex(con, width - 1, 0, 191, color, bgcolor)
    tcod.console_put_char_ex(con, 0, height - 1, 192, color, bgcolor)
    tcod.console_put_char_ex(con, width - 1, height - 1, 217, color, bgcolor)
github Wolfenswan / RoguelikeTut-TCOD / rendering / render_main.py View on Github external
if visible:
        if debug or game.state == GameState.SHOW_MAP:
            color = tile.fg_color
        else:
            color = darken_color_by_fov_distance(game.player, tile.fg_color, tile_x, tile_y, min = 0.3)
        tcod.console_put_char_ex(con, screen_x, screen_y, tile.char, color, colors.black)
        tile.explored = 50

    elif tile.explored > 0: #and not game.player.in_combat(game):
        # "forgetting" tiles disabled for now
        # if  game.state == GameState.PLAYERS_TURN:   # Only active player movement lowers tile exploration state
        #     tile.explored -= randint(0, 1)
        #if game.state == GameStates.PLAYER_RESTING: # Automap is only displayed outside of combat when actively pausing #
        color = tile.dark_color if not game.state == GameState.SHOW_MAP else tile.fg_color
        tcod.console_put_char_ex(con, screen_x, screen_y, tile.char, color, colors.black)