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()
def __init__(self, tilePos, texture, stageManager): Object.__init__(self, tilePos * stageManager.stage.tileSize, texture) self.__isMoving = False self.__stageManager = stageManager self.tile = tilePos self.nextPos = sf.Vector2(0., 0.) self.velocity = sf.Vector2(0., 0.) self.currDirection = Direction.STAY self.nextPos = sf.Vector2(48., 48.) self.__speed = 150 self.__directions = [Direction.STAY] self.__initAnimations()
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()