コード例 #1
0
def test_sys_custom_render(console):
    if libtcodpy.sys_get_renderer() != libtcodpy.RENDERER_SDL:
        pytest.xfail(reason='Only supports SDL')

    escape = []
    def sdl_callback(sdl_surface):
        escape.append(True)
        libtcodpy.console_set_dirty(0, 0, 0, 0)
    libtcodpy.sys_register_SDL_renderer(sdl_callback)
    libtcodpy.console_flush()
    assert escape, 'proof that sdl_callback was called'
コード例 #2
0
def test_sys_custom_render(console):
    if libtcodpy.sys_get_renderer() != libtcodpy.RENDERER_SDL:
        pytest.xfail(reason='Only supports SDL')

    escape = []
    def sdl_callback(sdl_surface):
        escape.append(True)
        libtcodpy.console_set_dirty(0, 0, 0, 0)
    libtcodpy.sys_register_SDL_renderer(sdl_callback)
    libtcodpy.console_flush()
    assert escape, 'proof that sdl_callback was called'
コード例 #3
0
# generate a callback for libtcod
@tcod.ffi.callback('SDL_renderer_t')
def sdl_hook(surface):
    # cast (void *) to (SDL_Surface *)
    surface = tcod.ffi.cast('SDL_Surface *', surface)

    # assume pixels are 32bit, mostly unsafe, but this is what libtcod uses
    pixels = tcod.ffi.cast('uint32*', surface.pixels)

    for y in range(surface.h):
        for x in range(surface.w):
            index = y * surface.w + x
            # make a simple animatied pattern
            bit = ((tick + x) % 100 < 50) ^ ((tick + y) % 100 < 50)
            pixels[index] = 0xffffffff * bit

if __name__ == '__main__':
    # hook callback to libtcod
    tcod.sys_register_SDL_renderer(sdl_hook)

    con = tdl.init(32, 32, renderer='SDL') # MUST BE SDL RENDERER

    tick = 0
    while(True):
        tick += 1
        for event in tdl.event.get():
            if event.type == 'QUIT':
                raise SystemExit()
        tdl.flush() # will call sdl_hook
コード例 #4
0
                    print('ei')
                    # load_scores()
                except:
                    msgbox('\n No high scores where found.\n', 24)
                    return 'wait'

            if choice == 3:  # quit
                break


tcod.console_set_custom_font('assets/Tileset.png', tcod.FONT_LAYOUT_ASCII_INROW, 16, 64)

#tcod.console_set_custom_font('assets/Tileset3.png', tcod.FONT_LAYOUT_ASCII_INROW,tcod.FONT_TYPE_GREYSCALE)
root = tcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Caves of the Mad Lich', False, tcod.RENDERER_SDL2,order='F')
tcod.sys_set_fps(LIMIT_FPS)
tcod.sys_register_SDL_renderer('assets/SDL_render_metal.m')



'''if CTML.con == None:
   cona = tcod.console.Console(MAP_WIDTH, MAP_HEIGHT, order="F")
   cona.clear(bg=(25, 0, 23), fg=(25, 0, 23))
   #tcod.console_set_default_background(cona, BACKGROUND_COLOR)'''



'''if CTML.panel == None:
   panela = tcod.console.Console(SCREEN_WIDTH, PANEL_HEIGHT + 2, order="F")
   panela.clear(fg=CTML.fg_tuple, bg=CTML.bg_tuple)'''