本文整理汇总了Python中clock.Clock.time_left方法的典型用法代码示例。如果您正苦于以下问题:Python Clock.time_left方法的具体用法?Python Clock.time_left怎么用?Python Clock.time_left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clock.Clock
的用法示例。
在下文中一共展示了Clock.time_left方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import time_left [as 别名]
def run(self):
"""Method that starts the game running."""
timeController = Clock(self.S_TURN)
self.isRunning = True
while self.isRunning:
# start turn
timeController.start()
leftTime = self.S_TURN
#TODO think if input should be processed inside the inner loop
# process user input to Game
self.iMngr.processUserInput(self)
#isRunning = not self.iMngr.closedGame()
while timeController.time_left() > self.S_UPDATE:
#sync with remote
self.nMngr.updateGame(self)
# update state of the game
self.uMngr.updateGame(self)
#newState = self.readState()
#self.world.update(newState)
# play sounds
self.sMngr.updateGame(self)
# render
self.gMngr.draw(timeController.time_left(), self)
#self.worldView.draw()
# sleep if necessary
timeController.sleep()
示例2: main
# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import time_left [as 别名]
def main():
cliMngr = ClientManager()
clock = Clock(FRAMETIME)
clock.start()
while True:
state = '{"team":[[10,10]],[[10,20]]}'
# check if there are new clients trying to conect
cliMngr.receive_connections()
# send game state to all clients
cliMngr.broadcast(state)
# read clients input while we can
timeout = clock.time_left()
cliMngr.read_incoming_msgs(timeout)
# drop clients that are not responsive
cliMngr.check_clients_liveness()
clock.sleep()
示例3: main
# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import time_left [as 别名]
def main(srvHost, srvPort):
w = dict()
em = EventManager()
nm = NetworkManager(em, w)
FRAME_TIME = 0.2 # 200 ms
c = Clock(FRAME_TIME)
c.start()
slept_time = 0.0
nm.start(srvHost, srvPort)
counter = 100
exit = False
while not exit:
nm.update(slept_time + c.time_passed())
counter -= 1
if counter <= 0:
exit = True
slept_time = c.time_left()
c.sleep()
print "%s" % (counter * FRAME_TIME)