当前位置: 首页>>代码示例>>Python>>正文


Python Timer.total方法代码示例

本文整理汇总了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
开发者ID:pfirsich,项目名称:Pywi,代码行数:62,代码来源:core.py


注:本文中的timer.Timer.total方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。