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


Python Timer.get_seconds方法代码示例

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


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

示例1: MainGame

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

#.........这里部分代码省略.........
            self.croc.move(self.croc.speed, 0)

            # Checks if the crocodile goes off the screen
            if self.croc.body_rect.left > self.width:
                self.croc.body_rect.left = self.logs[-1].rect.left - LOG_MARGIN
                self.croc.head_rect.left = self.logs[-1].rect.left - LOG_MARGIN + 80

            # Checks if the frog is on the crocodile
            if self.croc.body_rect.colliderect(self.frogs[0].rect) and \
               not self.croc.head_rect.colliderect(self.frogs[0].rect):

               self.frogs[0].horiz_speed = self.croc.speed 
               frogOnObject = True 
               frogOnCroc   = True 

            # Checks if the frog is on the crocodile's 
            # head. If so, the frog dies
            elif self.croc.head_rect.colliderect(self.frogs[0].rect) \
                 and self.croc.biting:
                self.killFrog()

        # If a frog is on a log or turtle, move the frog with it
        if frogOnObject and self.frogs[0].is_alive:
            self.frogs[0].move(self.frogs[0].horiz_speed, 0)

            # Check if the frog has gone out of bounds.
            # If so, the frog dies
            if self.frogs[0].rect.right < 0 or self.frogs[0].rect.left > self.width:
                self.killFrog()

    def placePowerups(self):

        # Place the fly in a goal every 12 seconds
        if self.fly_appear_timer.get_seconds() == 0 and not self.fly_shown:
            self.fly_timer.start()

            # place the fly in a random goal rectangle
            r = self.goalRects[random.randrange(len(self.goalRects))]

            # check if the rectangle picked is already taken up
            unoccupied = True  

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


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