示例#1
0
 def shootBullet(self):
     if gVariables.g_IS_FX:
         SFX(self.R._SFX[0])
     bullet = Sprite(self.R._BULLET[gVariables.g_PlayerIndex])
     bullet.position = (self.PLAYER.position[0] + bullet.width / 2,
                        self.PLAYER.position[1])
     bullet.cshape = CollisionModel.AARectShape(bullet.position,
                                                bullet.width / 2,
                                                bullet.height / 2)
     bullet.scale = 0.8
     bullet.velocity = (self.bullet_speed, 0)
     bullet.do(Move())
     self.bullet_Lists.add(bullet)
     self.collisionManager.add(bullet)
     self.batch.add(bullet, self.bulletZ)
    def addBrick(self, x, y, spriteBlock):
        x = x // blockSize * blockSize
        y = y // blockSize * blockSize

        if isinstance(spriteBlock, str):
            spriteObj = Sprite(spriteBlock)
        else:
            spriteObj = copy(spriteBlock)

        spriteObj.position = (x, y)
        spriteObj.cshape = cm.AARectShape(spriteObj.position,
                                          spriteObj.width // 2,
                                          spriteObj.height // 2)

        if self.collisions.objs_colliding(spriteObj):
            return

        self.collisions.add(spriteObj)
        self.add(spriteObj, z=2)