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


Python Block.constant方法代码示例

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


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

示例1: ColorDiffGame

# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import constant [as 别名]
class ColorDiffGame(gamelib.SimpleGame):
    BLACK = pygame.Color('black')
    WHITE = pygame.Color('white')
    GREEN = pygame.Color('green')
    
    def __init__(self):
        super(ColorDiffGame, self).__init__('ColorDiff', ColorDiffGame.WHITE)
        self.level = 2
        self.score = 0
        self.start_time = 60
        self.frame_count = 0
        self.frame_rate = 60
        self.total_seconds = 60



    def init(self):
        self.Repeat = 0
        super(ColorDiffGame, self).init()
        self.block = Block(color = ColorDiffGame.GREEN,level=self.level,score = self.score)
        self.startgame = False
        self.block.constant()
        self.render_score()

    def update(self):
        self.render_time()
        if pygame.mouse.get_pressed() == (1,0,0): # detect left click
            self.Repeat+=1
            if self.Repeat == 1:
                self.mouse_position = [self.posX,self.posY]
                self.block.is_clicked(self.mouse_position,self.level)

        else:
            self.Repeat = 0
            
            if self.block.is_pass() == True:
                self.score += 1
                print(self.score)
                if (self.score>25): self.level = 10
                elif (self.score>22): self.level = 9
                elif (self.score>18): self.level = 8
                elif (self.score>14): self.level = 7
                elif (self.score>10): self.level = 6
                elif (self.score>7): self.level = 5
                elif (self.score>4): self.level = 4
                elif (self.score>1): self.level = 3
            
                self.init()

        self.frame_count += 1
        self.total_seconds = self.start_time - (self.frame_count // self.frame_rate)
        
        if self.total_seconds < 0:
            self.done = True;
            self.total_seconds = 0
        

        
    def render_score(self):
        self.score_image = self.font.render("Score = %d" % self.score, 0, ColorDiffGame.GREEN)

    def render_time(self):
        self.time_image = self.font.render("Time left: {0} ".format(self.total_seconds), 0, ColorDiffGame.GREEN)
        


    def render(self, surface):
        self.block.render(surface,self.level,self.score)
        surface.blit(self.score_image, (100,640))
        surface.blit(self.time_image, (250,640))
开发者ID:inzzpk,项目名称:ColorDiff,代码行数:72,代码来源:main.py


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