本文整理汇总了Python中timer.Timer.total方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.total方法的具体用法?Python Timer.total怎么用?Python Timer.total使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timer.Timer
的用法示例。
在下文中一共展示了Timer.total方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import total [as 别名]
def run(self, dt):
"""Initialized Pywi and enters the mainloop.
stepCallback - This callback is called until the gameTime is bigger or equal to the real time.
dt - The time gameTime is incremented by in very simulation step
title - The window title
xres - The width of the window in pixels
yres - The height of the window in piyels
fullscreen - If the window created should be fullscreen (boolean)
vsync - If vsync should be enabled (boolean)
"""
mainLoopTimer = Timer()
fpsTimer = Timer()
#bench = Timer()
#stepcount = 0
#stepcum = 0
#framecount = 0
#framecum = 0
fpsRendered = 0
while not self._closeIssued:
while not self._closeIssued and self.gameTime < mainLoopTimer.total():
#bench.reset()
#print mainLoopTimer.total(),"-",self.gameTime,"=",mainLoopTimer.total()-self.gameTime
self._window.dispatch_events()
for obj in self.updateObjects:
obj.update()
self.step()
self.gameTime += dt
#d = bench.delta()
#stepcount += 1
#stepcum += d
#print "STEP current:", d
#print "STEP Avrg time:", float(stepcum)/stepcount
fpsRendered += 1
#bench.reset()
self.prepareFrame()
self._updateFrame()
#d = bench.delta()
#framecount += 1
#framecum += d
#print "FRAME current:", d
#print "FRAME Avrg time:", float(framecum)/framecount
if fpsTimer.total() > 1.0:
self._window.set_caption( self._title + " - FPS: " + str(fpsRendered) )
fpsRendered = 0
fpsTimer.reset()
#print "STEP COUNT: %d" % stepcount
#print "FRAME COUNT: %d" % framecount
self._terminate()
self.terminate() # Should be overload