本文整理汇总了Python中stopwatch.Stopwatch.tick方法的典型用法代码示例。如果您正苦于以下问题:Python Stopwatch.tick方法的具体用法?Python Stopwatch.tick怎么用?Python Stopwatch.tick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stopwatch.Stopwatch
的用法示例。
在下文中一共展示了Stopwatch.tick方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from stopwatch import Stopwatch [as 别名]
# 或者: from stopwatch.Stopwatch import tick [as 别名]
#.........这里部分代码省略.........
if cannon.direction > 0:
ball.x = cannon.x + cannon.width + ball.realR
else:
ball.x = cannon.x - ball.realR
def timerFiredPlay(self):
if (self.ball.x < self.maps.left
or self.ball.x > self.maps.left + self.maps.width or
self.ball.y < self.maps.top
or self.ball.y > self.maps.top + self.maps.height):
# Ball off map
self.killBall()
collided = pygame.sprite.spritecollide(self.ball, self.terrain, False,
Terrain.collidedFn)
if len(collided) > 0:
elements = Terrain.manageCollision(self.ball, collided)
for element, direction in elements:
result = element.interactFromDir(self.ball, direction)
if result == "score":
self.score += element.points
elif result == "win":
self.nextLevel()
elif result == "fly":
self.ballFly(self.ball, element)
elif result == "kill":
self.killBall()
self.ball.update(self.isKeyPressed)
def timerFired(self, dt):
if self.mode == "play":
self.timerFiredPlay()
self.stopwatch.tick(dt)
def drawMenu(self, screen):
titleTop = 70
titleLeft = 60
x = drawText(screen, titleLeft, titleTop,
text="Bouncy Bouncy ", font=self.font.title, anchor="nw")
space = 8
drawText(screen, x + space, titleTop, text="Revamped",
font=self.font.titleEmph, anchor="nw")
self.mainMenu.draw(screen, self.font.text)
def drawGame(self, screen):
self.terrain.draw(screen)
self.ball.draw(screen)
pos = 30
drawText(screen, self.margin, pos,
text="Level %s" % self.level, font=self.font.text, anchor="nw")
pos = 80
drawText(screen, self.margin, pos,
text="Score: %d" % self.score, font=self.font.text, anchor="nw")
pos = 110
drawText(screen, self.margin, pos, text="Highscore:",
font=self.font.text, anchor="nw")
pos = 130
drawText(screen, self.margin, pos, text=self.highscoreText,
font=self.font.text, anchor="nw")
self.drawGameTime(screen)
def drawGameTime(self, screen):
pos = 180
drawText(screen, self.margin, pos,
text=str(self.stopwatch), font=self.font.text, anchor="nw")