How to use the tcod.console_blit 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 eyeCube / Softly-Roguelike / rogue.py View on Github external
def refresh():  # final to root and flush
    libtcod.console_blit(con_final(), 0,0,window_w(),window_h(),  0, 0,0)
    libtcod.console_flush()
#@debug.printr
github ChadAMiller / roguelike-2019 / menus.py View on Github external
libtcod.console_set_default_foreground(window, libtcod.white)
    libtcod.console_print_rect_ex(window, 0, 0, width, height, libtcod.BKGND_NONE, libtcod.LEFT, header)

    # print all the options
    y = header_height
    letter_index = ord('a')
    for option_text in options:
        text = '(' + chr(letter_index) + ') ' + option_text
        libtcod.console_print_ex(window, 0, y, libtcod.BKGND_NONE, libtcod.LEFT, text)
        y += 1
        letter_index += 1

    # blit the contents of the "window" to the root console
    x = int(screen_width / 2 - width / 2)
    y = int(screen_height / 2 - height / 2)
    libtcod.console_blit(window, 0, 0, width, height, 0, x, y, 1.0, 0.7)
github libtcod / python-tcod / examples / samples_libtcodpy.py View on Github external
Sample('  Mouse support      ', render_mouse),
           Sample('  Name generator     ', render_name),
           Sample('  Python fast render ', render_py))
cur_sample = 0
credits_end = False
first = True
cur_renderer = 0
renderer_name=('F1 GLSL   ','F2 OPENGL ','F3 SDL    ','F4 SDL2   ','F5 OPENGL2')
key=libtcod.Key()
mouse=libtcod.Mouse()
while not libtcod.console_is_window_closed():
    libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS|libtcod.EVENT_MOUSE,key,mouse)
    # render the sample
    samples[cur_sample].func(first, key, mouse)
    first = False
    libtcod.console_blit(sample_console,
                         0, 0, SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT,
                         0, SAMPLE_SCREEN_X, SAMPLE_SCREEN_Y)
    # render credits
    if not credits_end:
        credits_end = libtcod.console_credits_render(60, 43, 0)
    # render sample list
    for i in range(len(samples)):
        if i == cur_sample:
            libtcod.console_set_default_foreground(None, libtcod.white)
            libtcod.console_set_default_background(None, libtcod.light_blue)
        else:
            libtcod.console_set_default_foreground(None, libtcod.grey)
            libtcod.console_set_default_background(None, libtcod.black)
        libtcod.console_print_ex(None, 2, 46 - (len(samples) - i),
                                   libtcod.BKGND_SET, libtcod.LEFT, samples[i].name)
    # render stats
github ChadAMiller / roguelike-2019 / render_functions.py View on Github external
libtcod.console_set_char_background(con, x, y, colors.get('dark_wall'), libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(con, x, y, colors.get('dark_ground'), libtcod.BKGND_SET)

    # Draw all entities in the list
    visible_entities = [e for e in game_map.entities if e.render_order != RenderOrder.INVISIBLE]
    entities_in_render_order = sorted(visible_entities, key=lambda x: x.render_order.value)

    for entity in entities_in_render_order:
        if game_state == GameStates.TARGETING and targeting_item.valid_target(mouse, fov_map, entity) and entity.distance(mouse.cx, mouse.cy) <= targeting_item.item.targeting_radius:
            libtcod.console_set_default_foreground(con, libtcod.darkest_red)
            libtcod.console_put_char(con, entity.x, entity.y, entity.char, libtcod.BKGND_NONE)
        else:
            draw_entity(con, entity, fov_map, game_map)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    # Print the game messages, one at a time
    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE, libtcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp, player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)
    libtcod.console_print_ex(panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT, '{}'.format(game_map.name))

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT, get_names_under_mouse(mouse, game_map.entities, fov_map))
github eyeCube / Softly-Roguelike / rogue.py View on Github external
def render_hud(pc) :
    con = misc.render_hud(hud_w(),hud_h(), pc, get_turn(), dlvl() )
    libtcod.console_blit(con,0,0,0,0, con_game(),hud_x(),hud_y())
def clear_final():
github BraininaBowl / RoguelikePy2019 / render_functions.py View on Github external
if (game_map.tiles[x][y].explored or visible) and wall:
                    libtcod.console_put_char(con, x*3, y*2, tiles.get('wall_tile'), libtcod.BKGND_NONE)
                    libtcod.console_put_char(con, x*3+1, y*2, tiles.get('wall_tile')+1, libtcod.BKGND_NONE)
                    libtcod.console_put_char(con, x*3+2, y*2, tiles.get('wall_tile')+2, libtcod.BKGND_NONE)
                    libtcod.console_put_char(con, x*3, y*2+1, tiles.get('wall_tile')+32, libtcod.BKGND_NONE)
                    libtcod.console_put_char(con, x*3+1, y*2+1, tiles.get('wall_tile')+33, libtcod.BKGND_NONE)
                    libtcod.console_put_char(con, x*3+2, y*2+1, tiles.get('wall_tile')+34, libtcod.BKGND_NONE)

    # Draw all entities in the list

    entities_in_render_order = sorted(entities, key=lambda x: x.render_order.value)

    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, anim_frame, game_map, game_state)

    libtcod.console_blit(con, 0,0,map_width*3, map_height*2, 0, -cam_x, -cam_y)



    libtcod.console_set_default_background(panel, colors.get('light'))
    libtcod.console_set_default_foreground(panel, colors.get('dark'))
    libtcod.console_clear(panel)

    # Print the game messages, one line at a time
    libtcod.console_print_ex(panel, int(panel_width / 2), 3, libtcod.BKGND_SET, libtcod.CENTER, "-------- Messages --------")


    libtcod.console_set_default_background(messages_pane, colors.get('light'))
    libtcod.console_clear(messages_pane)
    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(messages_pane, message.color)
github eyeCube / Softly-Roguelike / orangio.py View on Github external
def blit_console(self):
        tcod.console_blit(
            self.console,   0,0,self.w,self.h,
            0,      self.x,self.y
        )
github BraininaBowl / RoguelikePy2019 / render_functions.py View on Github external
libtcod.console_set_default_foreground(panel, colors.get('dark'))
    libtcod.console_set_default_background(panel, colors.get('light'))

    libtcod.console_blit(panel, 0, 0, panel_width, panel_height, 0, panel_x,0)

    tooltip_text = get_names_under_mouse(cam_x,cam_y,mouse, entities, fov_map)
    tooltip_len = len(tooltip_text)
    libtcod.console_set_default_background(tooltip, libtcod.black)
    libtcod.console_clear(tooltip)
    libtcod.console_set_default_foreground(tooltip, colors.get('light'))
    libtcod.console_set_default_background(tooltip, colors.get('dark'))
    libtcod.console_print_ex(tooltip, 0, 0, libtcod.BKGND_SET, libtcod.LEFT, tooltip_text)

    libtcod.console_set_key_color(tooltip,libtcod.black)
    libtcod.console_blit(tooltip, 0,0, tooltip_len, 1, 0, mouse.cx + 2, mouse.cy + 1)


    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Use or equip item.\n'
        else:
            inventory_title = 'Drop an item.\n'

        inventory_menu(con, inventory_title, player, 50, screen_width, screen_height)

    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, 'Level up! Choose a stat to raise:', player, 40, screen_width, screen_height)

    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 10, screen_width, screen_height)