当前位置: 首页>>代码示例>>Python>>正文


Python Manager.post方法代码示例

本文整理汇总了Python中Manager.Manager.post方法的典型用法代码示例。如果您正苦于以下问题:Python Manager.post方法的具体用法?Python Manager.post怎么用?Python Manager.post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Manager.Manager的用法示例。


在下文中一共展示了Manager.post方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init

# 需要导入模块: from Manager import Manager [as 别名]
# 或者: from Manager.Manager import post [as 别名]
def init():
    """
    Game initialization function.
        1. Creates a L{Debugger} (debugger) and L{EventTimer} (eventTimer) and 
           stores references to them in an instance of L{EventManager}.
        2. Several listeners are started and registered with eventManager:
            - Instance of L{Universe} (universe)
            - Instance of L{UserInterface} (ui)
            - Instance of L{Window} (gameWindow)
        3. We send the eventManager a message to start the game
            - This message is interpreted by the gameWindow
    """
    
    debugger = Debugger()
    eventTimer = EventTimer()
    
    #Create the event manager for low-level events
    eventManager = Manager(eventTimer,debugger) #FIXME: more specific manager\
                                                #classes will be needed later?
    try:                                            
        client = GameClient(eventManager,host='10.41.24.79',port=1567)
    except:
        pass
    
    #Create the occurence manager for high-level events (same across client and server)
    #FIXME: NOT YET IMPLEMENTED
    #Note: Do we even need this anymore? - Julian
    #Response: I don't think so.  - Jared
    
    #===========================================
    #Create and register the standard listeners
    #With the event manager
    #===========================================
    #FIXME: Not yet fully implemented
    
    #THIS WILL BE CHANGED LATER TO ACCOUNT FOR LOADING, ETC.

    # World w is set to the activeWorld of the universe
    universe = Universe(eventManager)
    ui = UserInterface(eventManager,universe.activeWorld)
    
    gameWindow = Window(eventManager,width=1024,height=768)
    
    w = World()
    universe.changeWorld(w)
    
    #===========================================
    
    # Initialize 500 entities in World w
    for i in range(100):
        #w.addEntity(Entity('ball.png',i*50,i*50, w, (255,255,255)))
        #w.addEntity(TestEntity('testBuilding.png', i*50, i*50, w, 'alpha'))
        w.addEntity(TestEntity('testCraft.png',i*50,i*50,w,'alpha'))

    eventManager.post(Event.WorldManipulationEvent())
    
    #Notify the manager that the window should start to accept input:
    eventManager.post(Event.StartEvent())
    return eventManager.eventTypesToListeners
开发者ID:jceipek,项目名称:Complete-Galactic-Dominion,代码行数:61,代码来源:testClient.py

示例2: init

# 需要导入模块: from Manager import Manager [as 别名]
# 或者: from Manager.Manager import post [as 别名]
def init(host='localhost',server=None):
    """
    Most of this code is copied from init() function in client.py
    
    Game initialization function.
        1. Creates a L{Debugger} (debugger) and L{EventTimer} (eventTimer) and 
           stores references to them in an instance of L{EventManager}.
        2. Several listeners are started and registered with eventManager:
            - Instance of L{Universe} (universe)
            - Instance of L{UserInterface} (ui)
            - Instance of L{Window} (gameWindow)
        3. We send the eventManager a message to start the game
            - This message is interpreted by the gameWindow
    """
    
    #Creates a Debugger that posts events to the terminal for debugging purposes
    debugger = Debugger()
    eventTimer = EventTimer()
    
    #Create the event manager for low-level events
    eventManager = Manager(eventTimer,debugger) #FIXME: more specific manager\
    Entity.manager = eventManager    

    # World w is set to the activeWorld of the universe
    universe = Universe(eventManager)
    ui = UserInterface(eventManager,universe.activeWorld,'BROADCASTSERVER')

    gameWindow = Window(eventManager,width=1024,height=768)
    gameWindow.fullscreenMode = False
    gameWindow.updateScreenMode()

    w = World(universe)
    s.world=w

    networked = True
    client = GameClient(eventManager,host=s.host,port=1567)

	#wait until the client is assigned an ID before proceeding
    while client.ID == None:
        import time
        time.sleep(.02)
    print 'Got an ID',client.ID
    clientID = client.ID

    ui.setClientID(clientID)

    wManipulator = WorldManipulator(eventManager,w,networked,gameClientID = clientID)
    
    #generate the resources in the server, the existance of these
    #resources will propogate through to every client when they connect
    w._generateResources()
    
    #Notify the manager that the window should start to accept input:
    eventManager.post(Event.StartEvent())

    return eventManager.eventTypesToListeners
开发者ID:jceipek,项目名称:Complete-Galactic-Dominion,代码行数:58,代码来源:broadcastServer.py

示例3: init

# 需要导入模块: from Manager import Manager [as 别名]
# 或者: from Manager.Manager import post [as 别名]
def init(host='localhost'):
    """
    Game initialization function.
        1. Creates a L{Debugger} (debugger) and L{EventTimer} (eventTimer) and
           stores references to them in an instance of L{EventManager}.
        2. Several listeners are started and registered with eventManager:
            - Instance of L{Universe} (universe)
            - Instance of L{UserInterface} (ui)
            - Instance of L{Window} (gameWindow)
        3. We send the eventManager a message to start the game
            - This message is interpreted by the gameWindow
    """

    debugger = Debugger()
    eventTimer = EventTimer()

    #Create the event manager for low-level events
    eventManager = Manager(eventTimer,debugger) #FIXME: more specific manager\
                                                #classes will be needed later?
    Entity.manager = eventManager

    #Create the occurence manager for high-level events (same across client and server)
    #FIXME: NOT YET IMPLEMENTED

    #THIS WILL BE CHANGED LATER TO ACCOUNT FOR LOADING, ETC.

    networked = True

    # World w is set to the activeWorld of the universe
    universe = Universe(eventManager)
    ui = UserInterface(eventManager,universe.activeWorld,None)

    gameWindow = Window(eventManager,width=1024,height=768)
    gameWindow.fullscreenMode = False
    gameWindow.updateScreenMode()

    w = World(universe)
    #universe.changeWorld(w)

    try:
        client = GameClient(eventManager,host=host,port=1567)
        while client.ID == None:
            import time
            time.sleep(.02)
        print 'Got an ID',client.ID
        clientID = client.ID
    #    client.sendRequest('GetWorld')

    except:
        networked = False

    if not networked:
        # Initialize 25 entities in World w
        # Initialize a TestTownCenter
        clientID = GameClient.ID = 0
        ui.setClientID(clientID)
        eventManager.post(Event.NewPlayerEvent(clientID))
        w._generateResources()
    else:
        clientID = client.ID
        ui.setClientID(clientID)

    wManipulator = WorldManipulator(eventManager,w,networked,gameClientID = clientID)

    #Notify the manager that the window should start to accept input:
    eventManager.post(Event.StartEvent())

    return eventManager.eventTypesToListeners
开发者ID:jceipek,项目名称:Complete-Galactic-Dominion,代码行数:70,代码来源:client.py


注:本文中的Manager.Manager.post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。