本文整理汇总了Python中engine.Engine.frameEnded方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.frameEnded方法的具体用法?Python Engine.frameEnded怎么用?Python Engine.frameEnded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类engine.Engine
的用法示例。
在下文中一共展示了Engine.frameEnded方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: frameEnded
# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import frameEnded [as 别名]
def frameEnded(self, frameTime):
self.timeUntilNextNetworkUpdate -= frameTime
if self.timeUntilNextNetworkUpdate <= 0.0:
self.networkUpdate()
Engine.frameEnded(self, frameTime)
self.sleep()
return self.network.reactor.running
示例2: frameEnded
# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import frameEnded [as 别名]
def frameEnded(self, frameTime, keyboard, mouse, joystick):
t = timer()
self.updateGUI(frameTime)
Engine.frameEnded(self, frameTime)
t.start()
self.updateChat(frameTime)
t.stop()
t.debugChatTime = t.time()
keyboard = keyboard
self.mouse = mouse
self.joystick = joystick
self.timeUntilNextNetworkUpdate -= frameTime
t.start()
if self.timeUntilNextNetworkUpdate <= 0.0:
self.timeUntilNextNetworkUpdate = self.timeBetweenNetworkUpdates
u = timer()
u.start()
self.network.update(frameTime)
u.stop()
for message in self.network._messages:
if message[1] > self.lastServerUpdate:
self.timeUntilNextEngineUpdate = message[Engine.NET_TIME_UNTIL_UPDATE]
#print message[Engine.NET_TIME_UNTIL_UPDATE]
self.lastServerUpdate = message[Engine.NET_TIME]
for object in self.objects:
object.existsOnServer = False
for serverObject in message[Engine.NET_OBJECTS]:
hasObject = False
for object in self.objects:
if serverObject[Engine.NET_OBJECTS_NAME] == object._name:
hasObject = True
object.existsOnServer = True
object.setAttributes(serverObject[Engine.NET_OBJECTS_ATTRIBUTES])
object.setEvents(serverObject[Engine.NET_OBJECTS_EVENTS])
if not hasObject:
newObject = None
if serverObject[2] == True:
newObject = Player(self, serverObject[Engine.NET_OBJECTS_NAME], self.camera)
self.chat.setNickName(serverObject[Engine.NET_OBJECTS_NAME])
newObject.enable()
self.player = newObject
else:
if serverObject[Engine.NET_OBJECTS_TYPE] == objects.PERSON:
newObject = Person(self, serverObject[Engine.NET_OBJECTS_NAME])
elif serverObject[Engine.NET_OBJECTS_TYPE] == objects.BULLET:
newObject = BulletObject(self, serverObject[Engine.NET_OBJECTS_NAME])
elif serverObject[Engine.NET_OBJECTS_TYPE] == objects.GRENADE:
newObject = GrenadeObject(self, serverObject[Engine.NET_OBJECTS_NAME])
elif serverObject[Engine.NET_OBJECTS_TYPE] == objects.SHRAPNEL:
newObject = ShrapnelObject(self, serverObject[Engine.NET_OBJECTS_NAME])
elif serverObject[Engine.NET_OBJECTS_TYPE] == objects.LASER:
newObject = LaserObject(self, serverObject[Engine.NET_OBJECTS_NAME])
else:
print "Unknown object to create", serverObject[Engine.NET_OBJECTS_TYPE], objects.PERSON
if newObject:
newObject.existsOnServer = True
newObject.setAttributes(serverObject[Engine.NET_OBJECTS_ATTRIBUTES])
newObject.setEvents(serverObject[Engine.NET_OBJECTS_EVENTS])
self.objects += [newObject]
for object in self.objects:
if not object.existsOnServer and object.type == objects.PERSON:
self.objects.remove(object)
object.close()
del object
self.network.clearMessages()
if self.player != None:
self.network.send(self.player.input(keyboard, self.mouse, self.joystick))
t.stop()
self.debugNetworkTime = t.time()
return True # Keep running