bacon/game.py
def run(game):
    '''Start running the game.  The window is created and shown at this point, and then
    the main event loop is entered.  'game.on_tick' and other event handlers are called
    repeatedly until the game exits.

    If a game is already running, this function replaces the :class:`Game` instance that
    receives events.
    '''
    if bacon._current_game:
        bacon._current_game = game
        return

    global _tick_callback_handle
    bacon._current_game = game

    # Window handler
    window_resize_callback_handle = lib.WindowResizeEventHandler(window._window_resize_event_handler)
    lib.SetWindowResizeEventHandler(window_resize_callback_handle)

    # Key handler
    key_callback_handle = lib.KeyEventHandler(keyboard._key_event_handler)
    lib.SetKeyEventHandler(key_callback_handle)

    # Mouse handlers
    mouse_button_callback_handle = lib.MouseButtonEventHandler(mouse_input._mouse_button_event_handler)
    lib.SetMouseButtonEventHandler(mouse_button_callback_handle)
    mouse_scroll_callback_handle = lib.MouseScrollEventHandler(mouse_input._mouse_scroll_event_handler)
    lib.SetMouseScrollEventHandler(mouse_scroll_callback_handle)

    # Controller handlers
    controller_connected_handle = lib.ControllerConnectedEventHandler(controller._controller_connected_event_handler)
    lib.SetControllerConnectedEventHandler(controller_connected_handle)
    controller_button_handle = lib.ControllerButtonEventHandler(controller._controller_button_event_handler)
    lib.SetControllerButtonEventHandler(controller_button_handle)
    controller_axis_handle = lib.ControllerAxisEventHandler(controller._controller_axis_event_handler)
    lib.SetControllerAxisEventHandler(controller_axis_handle)

    # Tick handler
    _tick_callback_handle = lib.TickCallback(_first_tick_callback)
    lib.SetTickCallback(_tick_callback_handle)

    lib.Run()
    bacon._current_game = None
    _tick_callback_handle = None

    lib.SetWindowResizeEventHandler(lib.WindowResizeEventHandler(0))
    lib.SetKeyEventHandler(lib.KeyEventHandler(0))
    lib.SetMouseButtonEventHandler(lib.MouseButtonEventHandler(0))
    lib.SetMouseScrollEventHandler(lib.MouseScrollEventHandler(0))
    lib.SetControllerConnectedEventHandler(lib.ControllerConnectedEventHandler(0))
    lib.SetControllerButtonEventHandler(lib.ControllerButtonEventHandler(0))
    lib.SetControllerAxisEventHandler(lib.ControllerAxisEventHandler(0))
    lib.SetTickCallback(lib.TickCallback(0))
def run(game):
    '''Start running the game.  The window is created and shown at this point, and then
    the main event loop is entered.  'game.on_tick' and other event handlers are called
    repeatedly until the game exits.

    If a game is already running, this function replaces the :class:`Game` instance that
    receives events.
    '''
    if bacon._current_game:
        bacon._current_game = game
        return

    global _tick_callback_handle
    bacon._current_game = game

    # Window handler
    window_resize_callback_handle = lib.WindowResizeEventHandler(window._window_resize_event_handler)
    lib.SetWindowResizeEventHandler(window_resize_callback_handle)

    # Key handler
    key_callback_handle = lib.KeyEventHandler(keyboard._key_event_handler)
    lib.SetKeyEventHandler(key_callback_handle)

    # Mouse handlers
    mouse_button_callback_handle = lib.MouseButtonEventHandler(mouse_input._mouse_button_event_handler)
    lib.SetMouseButtonEventHandler(mouse_button_callback_handle)
    mouse_scroll_callback_handle = lib.MouseScrollEventHandler(mouse_input._mouse_scroll_event_handler)
    lib.SetMouseScrollEventHandler(mouse_scroll_callback_handle)

    # Controller handlers
    controller_connected_handle = lib.ControllerConnectedEventHandler(controller._controller_connected_event_handler)
    lib.SetControllerConnectedEventHandler(controller_connected_handle)
    controller_button_handle = lib.ControllerButtonEventHandler(controller._controller_button_event_handler)
    lib.SetControllerButtonEventHandler(controller_button_handle)
    controller_axis_handle = lib.ControllerAxisEventHandler(controller._controller_axis_event_handler)
    lib.SetControllerAxisEventHandler(controller_axis_handle)

    # Tick handler
    _tick_callback_handle = lib.TickCallback(_first_tick_callback)
    lib.SetTickCallback(_tick_callback_handle)

    lib.Run()
    bacon._current_game = None
    _tick_callback_handle = None

    lib.SetWindowResizeEventHandler(lib.WindowResizeEventHandler(0))
    lib.SetKeyEventHandler(lib.KeyEventHandler(0))
    lib.SetMouseButtonEventHandler(lib.MouseButtonEventHandler(0))
    lib.SetMouseScrollEventHandler(lib.MouseScrollEventHandler(0))
    lib.SetControllerConnectedEventHandler(lib.ControllerConnectedEventHandler(0))
    lib.SetControllerButtonEventHandler(lib.ControllerButtonEventHandler(0))
    lib.SetControllerAxisEventHandler(lib.ControllerAxisEventHandler(0))
    lib.SetTickCallback(lib.TickCallback(0))
def run ( game ) : if bacon . _current_game : bacon . _current_game = game return global _tick_callback_handle bacon . _current_game = game # Window handler window_resize_callback_handle = lib . WindowResizeEventHandler ( window . _window_resize_event_handler ) lib . SetWindowResizeEventHandler ( window_resize_callback_handle ) # Key handler key_callback_handle = lib . KeyEventHandler ( keyboard . _key_event_handler ) lib . SetKeyEventHandler ( key_callback_handle ) # Mouse handlers mouse_button_callback_handle = lib . MouseButtonEventHandler ( mouse_input . _mouse_button_event_handler ) lib . SetMouseButtonEventHandler ( mouse_button_callback_handle ) mouse_scroll_callback_handle = lib . MouseScrollEventHandler ( mouse_input . _mouse_scroll_event_handler ) lib . SetMouseScrollEventHandler ( mouse_scroll_callback_handle ) # Controller handlers controller_connected_handle = lib . ControllerConnectedEventHandler ( controller . _controller_connected_event_handler ) lib . SetControllerConnectedEventHandler ( controller_connected_handle ) controller_button_handle = lib . ControllerButtonEventHandler ( controller . _controller_button_event_handler ) lib . SetControllerButtonEventHandler ( controller_button_handle ) controller_axis_handle = lib . ControllerAxisEventHandler ( controller . _controller_axis_event_handler ) lib . SetControllerAxisEventHandler ( controller_axis_handle ) # Tick handler _tick_callback_handle = lib . TickCallback ( _first_tick_callback ) lib . SetTickCallback ( _tick_callback_handle ) lib . Run ( ) bacon . _current_game = None _tick_callback_handle = None lib . SetWindowResizeEventHandler ( lib . WindowResizeEventHandler ( 0 ) ) lib . SetKeyEventHandler ( lib . KeyEventHandler ( 0 ) ) lib . SetMouseButtonEventHandler ( lib . MouseButtonEventHandler ( 0 ) ) lib . SetMouseScrollEventHandler ( lib . MouseScrollEventHandler ( 0 ) ) lib . SetControllerConnectedEventHandler ( lib . ControllerConnectedEventHandler ( 0 ) ) lib . SetControllerButtonEventHandler ( lib . ControllerButtonEventHandler ( 0 ) ) lib . SetControllerAxisEventHandler ( lib . ControllerAxisEventHandler ( 0 ) ) lib . SetTickCallback ( lib . TickCallback ( 0 ) )
Start running the game.  The window is created and shown at this point, and then
    the main event loop is entered.  'game.on_tick' and other event handlers are called
    repeatedly until the game exits.

    If a game is already running, this function replaces the :class:`Game` instance that
    receives events.
Start running the game . The window is created and shown at this point and then the main event loop is entered . game . on_tick and other event handlers are called repeatedly until the game exits .