本文整理汇总了Python中World.World._generateResources方法的典型用法代码示例。如果您正苦于以下问题:Python World._generateResources方法的具体用法?Python World._generateResources怎么用?Python World._generateResources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World.World
的用法示例。
在下文中一共展示了World._generateResources方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from World import World [as 别名]
# 或者: from World.World import _generateResources [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
示例2: init
# 需要导入模块: from World import World [as 别名]
# 或者: from World.World import _generateResources [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