Esempio n. 1
0
File: gui.py Progetto: jcandres/deth
def draw_main_menu(con, has_file=False):
    tcod.console_set_default_foreground(con, COL_A)
    img = tcod.image_load('small.png')
    tcod.image_set_key_color(img, tcod.red)
    tcod.image_blit(img, 0, 45, 30,  tcod.BKGND_LIGHTEN, .5, .25, 0)
    
    xx=-20
    yy=15
    
    can_cont = ""
    can_del = ''
    if has_file:
        can_cont = '-- (c)ontinue'
        can_del = '-- (D)elete'
    options=(
             """
             GAME TITLE """+chr(tcod.CHAR_BLOCK2)+chr(tcod.CHAR_BLOCK1)+chr(tcod.CHAR_BLOCK1)+"""
             |
             |
             \t-- (n)ew game
             |
             \t--\t%s
             |  |
             |  \t%s
             |
             \t-- (esc)cape
             """
             % (can_cont, can_del)
            )
    tcod.console_print_ex(con, game.GAME_WIDTH/4+xx, game.GAME_HEIGHT/3+yy,
                              tcod.BKGND_LIGHTEN, tcod.LEFT,options)
    
    tcod.console_print(con, 2, game.GAME_HEIGHT-2, 'oyyooyoyoyoyyooyoyoy')
    tcod.console_flush()
    tcod.console_clear(con)
Esempio n. 2
0
def test_image(console, tmpdir):
    img = libtcodpy.image_new(16, 16)
    libtcodpy.image_clear(img, libtcodpy.Color(0, 0, 0))
    libtcodpy.image_invert(img)
    libtcodpy.image_hflip(img)
    libtcodpy.image_rotate90(img)
    libtcodpy.image_vflip(img)
    libtcodpy.image_scale(img, 24, 24)
    libtcodpy.image_set_key_color(img, libtcodpy.Color(255, 255, 255))
    libtcodpy.image_get_alpha(img, 0, 0)
    libtcodpy.image_is_pixel_transparent(img, 0, 0)
    libtcodpy.image_get_size(img)
    libtcodpy.image_get_pixel(img, 0, 0)
    libtcodpy.image_get_mipmap_pixel(img, 0, 0, 1, 1)
    libtcodpy.image_put_pixel(img, 0, 0, libtcodpy.Color(255, 255, 255))
    libtcodpy.image_blit(img, console, 0, 0, libtcodpy.BKGND_SET, 1, 1, 0)
    libtcodpy.image_blit_rect(img, console, 0, 0, 16, 16, libtcodpy.BKGND_SET)
    libtcodpy.image_blit_2x(img, console, 0, 0)
    libtcodpy.image_save(img, tmpdir.join('test.png').strpath)
    libtcodpy.image_delete(img)

    # Not portable.
    #img = libtcodpy.image_from_console(console)
    #libtcodpy.image_refresh_console(img, console)
    #libtcodpy.image_delete(img)

    libtcodpy.image_delete(libtcodpy.image_load('../data/img/circle.png'))
Esempio n. 3
0
def render_all():
    global color_dark_wall, color_light_wall
    global color_dark_ground, color_light_ground
    global pix

    libtcod.image_blit(pix, con, 20, 20, libtcod.BKGND_SET, 0.3, 0.3, 0)

    # go through all tiles, and set their background color
    # for y in range(MAP_HEIGHT):
    #    for x in range(MAP_WIDTH):
    #        wall = map[x][y].block_sight
    #        if wall:
    #            libtcod.console_set_char_background(con, x, y, color_dark_wall, libtcod.BKGND_SET)
    #        else:
    #            libtcod.console_set_char_background(con, x, y, color_dark_ground, libtcod.BKGND_SET)

    # draw all objects in the list
    for object in objects:
        object.draw()

    # blit the contents of "con" to the root console
    libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
Esempio n. 4
0
    elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT):
        player.move(1, 0)


#############################################
# Initialization & Main Loop
#############################################

libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'python/libtcod tutorial', False)
libtcod.sys_set_fps(LIMIT_FPS)
con = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)

pix = libtcod.image_load("map.png")
libtcod.image_blit(pix, con, 20, 20, libtcod.BKGND_SET, 0.3, 0.3, 0)

# create object representing the player
player = Object(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, '@', libtcod.black)

# create an NPC
# npc = Object(SCREEN_WIDTH / 2 - 5, SCREEN_HEIGHT / 2, '@', libtcod.yellow)

# the list of objects with those two
objects = [player]

# generate map (at this point it's not drawn to the screen)
make_map()

while not libtcod.console_is_window_closed():