コード例 #1
0
ファイル: explosion.py プロジェクト: klempka/ExploDude
    def __init__(self, centerTilePos, radiusInTile):
        Object.__init__(self, centerTilePos * self.stage.tileSize, Explosion.texture)
        self.spritesPos = [[], [], [], []]
        self.tilesPos = []
        self.sideSprites = (sf.Sprite, sf.Sprite)
        self.currTime = 0.
        self.over = False

        row = lambda tilePos, offSet: (tilePos.x +
                                       tilePos.y *
                                       self.stage.tilesCount.x +
                                       offSet)
        column = lambda tilePos, offSet: (tilePos.x +
                                          (tilePos.y + offSet) *
                                          self.stage.tilesCount.x)

        isObstacle = lambda tile: utils.checkBit(tile.bits, Tile.Obstacle) == 1

        spritePos = lambda tilePos: tilePos * self.stage.tileSize

        tileOffSet = 1
        while radiusInTile >= tileOffSet and not isObstacle(self.stage.tiles[row(centerTilePos, tileOffSet)]):
            self.spritesPos[0].append(spritePos(sf.Vector2(centerTilePos.x + tileOffSet,
                                                        centerTilePos.y)))
            tileOffSet += 1

        animationInfo = AnimationInfo()
        animationInfo.firstFrameRect = sf.Rectangle((0, 0), (48, 48))
        animationInfo.sprite = self.sprite
        animationInfo.frameSize = 48
        animationInfo.frameTime = 0.1
        animationInfo.frameCount = 3

        self.centerAnimation = Animation(animationInfo).start()
コード例 #2
0
ファイル: dynamite.py プロジェクト: klempka/ExploDude
    def __init__(self, tilePos):
        Object.__init__(self, tilePos * Dynamite.stageManager.stage.tileSize, Dynamite.texture)
        self.currTime = Dynamite.explosionTime
        self.tilePos = tilePos
        self.exploded = False

        animationInfo = AnimationInfo()
        animationInfo.firstFrameRect = Rectangle((0, 0), (self.stageManager.stage.tileSize.x,
                                                          self.stageManager.stage.tileSize.y))
        animationInfo.frameCount = Dynamite.ANIMATION_FRAME_COUNT
        animationInfo.frameTime = Dynamite.ANIMATION_FRAME_TIME
        animationInfo.frameSize = self.stageManager.stage.tileSize
        animationInfo.sprite = self.sprite

        self.animation = Animation(animationInfo).start()
コード例 #3
0
ファイル: player.py プロジェクト: klempka/ExploDude
    def __initAnimations(self):
        upAnimationInfo = AnimationInfo()
        upAnimationInfo.firstFrameRect = sf.Rectangle((0, 48), (48, 48))
        upAnimationInfo.sprite = self.sprite
        upAnimationInfo.frameSize = 48
        upAnimationInfo.frameTime = 0.1
        upAnimationInfo.frameCount = 3
        downAnimationInfo = copy.deepcopy(upAnimationInfo)
        downAnimationInfo.firstFrameRect.top = 96
        leftAnimationInfo = copy.deepcopy(upAnimationInfo)
        leftAnimationInfo.firstFrameRect.top = 0
        rightAnimationInfo = copy.deepcopy(leftAnimationInfo)
        rightAnimationInfo.firstFrameRect.width = -48

        self.__upAnimation = Animation(upAnimationInfo)
        self.__downAnimation = Animation(downAnimationInfo)
        self.__leftAnimation = Animation(leftAnimationInfo)
        self.__rightAnimation = Animation(rightAnimationInfo)
        self.__currAnimation = self.__downAnimation.start()