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


Python Timer.toggle_pause方法代码示例

本文整理汇总了Python中Timer.toggle_pause方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.toggle_pause方法的具体用法?Python Timer.toggle_pause怎么用?Python Timer.toggle_pause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timer的用法示例。


在下文中一共展示了Timer.toggle_pause方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MainGame

# 需要导入模块: import Timer [as 别名]
# 或者: from Timer import toggle_pause [as 别名]

#.........这里部分代码省略.........
                for i in self.winning_frogs:
                    if i.rect.colliderect(r):
                        unoccupied = False 


            # Place the fly and tell draw() to draw it
            self.fly.rect.left = r.left + 2
            self.fly.rect.top  = r.top + 2
            self.fly_shown = True 

        # Hide the fly 6 seconds after being shown
        elif self.fly_timer.get_seconds() == 0 and self.fly_shown:
            self.fly_shown = False 
            self.fly_appear_timer.reset()


    # Checks if the game is over,
    # Changes the timer,
    # Toggles the fly
    # Handles other logic
    def play(self):

        if not self.fly_appear_timer.is_started():
            self.fly_appear_timer.start()

        # End the game if the player is out of lives
        if self.lives == 0:
            self.message = "Game over. You need more practice."
            self.messageSurface = self.font.render(self.message, True, (255, 255, 255))
            self.game_over = True 
            if self.game_over_time == 0:
                self.game_over_time = pygame.time.get_ticks()
            
            self.timer.toggle_pause()

        # End the game if the level limit has been reached
        if self.level >= MAX_LEVELS:
            self.game_over = True 
            self.message = "For more levels, send $10 to [email protected]"
            self.messageSurface = self.font.render(self.message, True, (255, 255, 255))

            if self.game_over_time == 0:
                self.game_over_time = pygame.time.get_ticks()

        self.timeSinceNew = self.timer.get_seconds()

        # Check if the timer ran out
        if self.timeSinceNew == 0:
            # frog will die, new one spawn
            self.killFrog()
            self.timer.reset()
            pass 

        if len(self.frogs) > 0:
            # Play the frog's animation if it's jumping
            if self.frogs[0].jumping or self.frogs[0].died_by_water:
                self.frogs[0].update(pygame.time.get_ticks())

                if self.frogs[0].current_clip == self.frogs[0].max_frames - 1:
                    # self.frogs[0].reset_jump_flags()
                    self.frogs[0].jumping = False 

        self.moveObjects()
        self.placePowerups()

    # Helper function.
开发者ID:nickihilker,项目名称:frogger-1,代码行数:70,代码来源:MainGame.py


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