示例#1
0
def init(main_flow: object):
    """
    游戏流程初始化
    Keyword argument:
    main_flow -- 游戏主流程
    """
    global def_style
    io_init.clear_screen()
    io_init.clear_order()
    flow_handle.cmd_clear()
    # 载入按键监听
    key_listion_event.on_wframe_listion()
    # 设置背景颜色
    io_init.set_background(normal_config.config_normal.background)
    # 初始化字体
    io_init.init_style()
    # 初始化地图数据
    global _main_flow
    _main_flow = main_flow

    _have_run = False

    def run_main_flow():
        nonlocal _have_run
        while True:
            if not _have_run:
                main_flow()
                _have_run = True
            askfor_order()
            flow_handle.call_default_flow()
            if flow_handle.exit_flag:
                break

    run_main_flow()
示例#2
0
def reset():
    """
    重启游戏
    """
    global _main_flow
    io_init.io_clear_cmd()
    io_init.clear_screen()
    io_init.clear_order()
    init(_main_flow)
示例#3
0
def init(main_flow: Callable):
    """
    游戏流程初始化
    Keyword argument:
    main_flow -- 游戏主流程
    """
    global def_style
    io_init.clear_screen()
    io_init.clear_order()
    flow_handle.cmd_clear()
    # 载入按键监听
    key_listion_event.on_wframe_listion()
    # 设置背景颜色
    io_init.set_background(game_data.game_data["core_cfg"]["background_color"])
    # 初始化字体
    io_init.init_style()
    # 初始化地图数据
    cache_contorl.map_data = game_data.game_data[game_config.language]["map"]
    cache_contorl.scene_data = game_data.scene_data
    cache_contorl.map_data = game_data.map_data
    flow_handle.reset_func = reset
    global _main_flow
    _main_flow = main_flow

    _have_run = False

    def run_main_flow():
        nonlocal _have_run
        while True:
            if not _have_run:
                main_flow()
                _have_run = True
            askfor_order()
            flow_handle.call_default_flow()
            if flow_handle.exit_flag:
                break

    run_main_flow()