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