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


Python Timer.is_started方法代码示例

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


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

示例1: MainGame

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

#.........这里部分代码省略.........

            for i in self.winning_frogs:
                if i.rect.colliderect(r):
                    unoccupied = False 

            # Place the fly in a goal that is not 
            # taken up by a frog
            while not unoccupied:
                unoccupied = True 
                r = self.goalRects[random.randrange(len(self.goalRects))]

                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
开发者ID:nickihilker,项目名称:frogger-1,代码行数:70,代码来源:MainGame.py


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