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


Python Background.sky方法代码示例

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


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

示例1: __init__

# 需要导入模块: from background import Background [as 别名]
# 或者: from background.Background import sky [as 别名]
class Avata:
    def __init__(self):
        self.background = Background()
        self.shot = Fire()
        self.senary = Senary()
        self.trilha = pygame.mixer.Sound(os.path.join("sound","trilha.wav"))
        self.tiro = pygame.mixer.Sound(os.path.join("sound",'tiro.wav'))
        self.porrada = pygame.mixer.Sound(os.path.join("sound",'porrada.wav'))
        self.morreu = pygame.mixer.Sound(os.path.join("sound",'morreu.wav'))
        self.trilha.play(-1)
        self.img = pygame.Surface((80,120))
        self.img = pygame.image.load(os.path.join("img",'joao1.png'))
        self.imgS = pygame.image.load(os.path.join("img",'joao2.png'))
        self.imgC = pygame.image.load(os.path.join("img",'joao1c.png'))
        self.imgSC = pygame.image.load(os.path.join("img",'joao2c.png'))
        self.img.set_colorkey((10,255,0),0)
        self.img.set_alpha(255,0)
        self.img2 = pygame.Surface((80,120))
        self.img2.set_colorkey((10,255,0),0)
        self.img2.set_alpha(255,0)
        self.pos = pygame.Rect((120,320,80,120))
        self.jump = 0
        self.jump_h = 11
        self.life = 5
        self.face = 1
        self.x = 0
        self.contx = 0
        self.step = 1
        self.score = 0
        self.moveActivedJump = 1 
        draw(self.img,(self.pos.left,self.pos.top))
        self.background.sky()
        self.drawLife()
    def move(self,key):
        self.background.redraw()
        if key == 273 and (self.jump_h == 11 or not self.moveActivedJump):
            self.jump = 1
            if self.moveActivedJump:
                self.jump_h = 0
            else:
                self.jump_h = 4
        elif key == 275:
            self.moveActived = 1
            self.step *= -1
            for i in range(len(self.senary.stone)-1):
                if self.pos.collidepoint(self.senary.stone[i].left-10,self.senary.stone[i].top):
                    self.moveActived = 0
            if self.moveActived:
                if self.pos.left >= 200:
                    self.background.move(key)
                    self.senary.move(-1)
                else:
                    self.pos.move_ip(10,0)
                self.face = 1
        elif key == 276:
            self.moveActived = 1
            self.step *= -1
            for i in range(len(self.senary.stone)-1):
                if self.pos.collidepoint(self.senary.stone[i].right,self.senary.stone[i].top):
                    self.moveActived = 0
            if self.moveActived:
                if self.pos.left == 100:
                    self.background.move(key)
                    self.senary.move(1)
                else:
                    self.pos.move_ip(-10,0)
                self.face = 0
        if self.jump:
            self.pos.move_ip(0,-20)
        if self.jump_h < 10: self.jump_h +=1
        self.moveActivedJump = 1
        for i in range(len(self.senary.stone)-1):
            if self.pos.collidepoint(self.senary.stone[i].right,self.senary.stone[i].top-10) or self.pos.collidepoint(self.senary.stone[i].left,self.senary.stone[i].top-10):
                self.moveActivedJump = 0
        if self.jump_h == 10 and self.moveActivedJump:
            if self.pos.top < 320:
                self.pos.move_ip(0,20)
            else : self.jump_h += 1
            self.jump = 0
        if key == 32:
            self.tiro.play()
            self.shot.fire(self.pos.center,self.face,1)
        self.ia()
        if len(self.shot.dir):
            self.shot.move()
            i=-1
            while i != len(self.shot.dir)-1:
                i+=1
                for j in range(len(self.senary.stone)-1):
                    if self.shot.pos[i].colliderect(self.senary.stone[j]):
                        self.shot.dir.pop(i)
                        self.shot.pos.pop(i)
                        self.shot.origem.pop(i)
                        i-=1
                        break
            i=-1
            while i != len(self.shot.dir)-1:
                i+=1 
                for j in range(len(self.senary.inimigo)-1):
                    if self.shot.pos[i].colliderect(self.senary.inimigo[j]) and self.shot.origem[i]:
#.........这里部分代码省略.........
开发者ID:pugpe,项目名称:auto_da_compadecida,代码行数:103,代码来源:avata.py


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