Exemplo n.º 1
0
    def __init__(self, x, y, w, h, properties, game):

        self.spritePath = './Assets/Objects/coin.png'
        self.game = game
        self.setProperties(properties)
        self.spriteBaseSize = 16
        self.topoffset = 5
        self.xoffset = 5

        self.x, self.y, self.w, self.h = x, y, 32, 32
        self.startQTBoundaries(self.x, self.y, self.w, self.h)

        self.collide = True
        self.collectable = True
        self.collected = False
        self.collisionExecuted = False

        # IDLE Graphics
        self.idleSprite = SpriteSheet(pygame.image.load(self.spritePath))
        self.idleAnimation = SpriteAnimation(4, 10, True)
        self.idleState = [
            self.idleSprite.getimage(self.spriteBaseSize * x, 0,
                                     self.spriteBaseSize, self.spriteBaseSize)
            for x in range(self.idleAnimation.framesQuantity)
        ]
        self.game.animationSystem.addAnimation(self.idleAnimation)
Exemplo n.º 2
0
    def __init__(self, x, y, w, h, properties, game):

        self.spritePath = './Assets/Objects/computer.png'
        self.game = game
        self.spriteBaseSize = 16
        self.topoffset = 5
        self.xoffset = 0
        self.setProperties(properties)

        self.x, self.y, self.w, self.h = x, y, 32, 32
        self.startQTBoundaries(self.x, self.y, self.w, self.h)

        self.collide = True
        self.collectable = True
        self.collected = False
        self.collisionExecuted = False
        self.inContactWithPlayer = False
        self.activationDelay = 20
        self.activationDelayMax = 20

        self.idleSprite = SpriteSheet(pygame.image.load(self.spritePath))
        self.idleAnimation = SpriteAnimation(4, 30, True)
        self.idleState = [
            self.idleSprite.getimage(32 * x, 0, 32, self.spriteBaseSize)
            for x in range(self.idleAnimation.framesQuantity)
        ]
        self.game.animationSystem.addAnimation(self.idleAnimation)
Exemplo n.º 3
0
    def __init__(self, x, y, w, h, properties, game):
        self.x, self.y, self.w, self.h = x, y, 32, 32
        self.startQTBoundaries(self.x, self.y, self.w, self.h)
        self.setProperties(properties)

        self.spritePath = './Assets/Objects/water_surface_blue.png'
        self.spritePathBorder = './Assets/Objects/water_surface.png'
        if self.have('color'):
            color = self.get('color')
            self.spritePath = self.spritePath.replace('blue', color)

        self.game = game
        self.spriteBaseSize = 16
        self.topoffset = 5
        self.xoffset = 5

        self.collide = True
        self.collectable = True
        self.collisionExecuted = False

        # IDLE Graphics
        self.idleSprite = SpriteSheet(pygame.image.load(self.spritePath))
        self.idleAnimation = SpriteAnimation(8, 10, True)
        self.idleState = [
            self.idleSprite.getimage(self.spriteBaseSize * x, 0,
                                     self.spriteBaseSize, self.spriteBaseSize)
            for x in range(self.idleAnimation.framesQuantity)
        ]
        self.game.animationSystem.addAnimation(self.idleAnimation)

        self.idleSpriteBorder = SpriteSheet(
            pygame.image.load(self.spritePathBorder))
        self.idleAnimationBorder = SpriteAnimation(8, 10, True)
        self.idleStateBorder = [
            self.idleSpriteBorder.getimage(self.spriteBaseSize * x, 0,
                                           self.spriteBaseSize,
                                           self.spriteBaseSize)
            for x in range(self.idleAnimationBorder.framesQuantity)
        ]
        self.game.animationSystem.addAnimation(self.idleAnimationBorder)
Exemplo n.º 4
0
    def setupSprite(self):
        # IDLE
        self.idleSprite = SpriteSheet(
            pygame.image.load(self.spritePathPrefix + 'bat_idle.png'))
        self.idleAnimation = SpriteAnimation(4, 30, True)
        self.idleState = [
            self.idleSprite.getimage(self.spriteBaseSize * x, 0,
                                     self.spriteBaseSize, self.spriteBaseSize)
            for x in range(self.idleAnimation.framesQuantity)
        ]
        self.game.animationSystem.addAnimation(self.idleAnimation)

        # WALK
        self.walkSprite = SpriteSheet(
            pygame.image.load(self.spritePathPrefix + 'bat_walk.png'))
        self.walkAnimation = SpriteAnimation(4, 10, True)
        self.walkState = [
            self.walkSprite.getimage(self.spriteBaseSize * x, 0,
                                     self.spriteBaseSize, self.spriteBaseSize)
            for x in range(self.walkAnimation.framesQuantity)
        ]
        self.game.animationSystem.addAnimation(self.walkAnimation)
Exemplo n.º 5
0
    def __init__(self,x,y,w,h,path,loop,frameQuantity,frameSpeed):
        self.x = x
        self.y = y
        self.w = w
        self.h = h
        self.life = frameQuantity*frameSpeed
        self.loop = loop
        self.frameQuantity = frameQuantity
        self.frameSpeed = frameSpeed

        self.sprite = SpriteSheet(pygame.image.load(path))
        self.animation = SpriteAnimation(frameQuantity,frameSpeed,loop)
        self.effect = [self.sprite.getimage(x * self.w,0,self.w,self.h) for x in range(frameQuantity)]
Exemplo n.º 6
0
    def __init__(self, x, y, w, h, properties, game):

        self.spritePathOpen = './Assets/Objects/door_open.png'
        self.spritePathClosed = './Assets/Objects/door_close.png'
        self.spritePathOpenCoin = './Assets/Objects/door_open_coin.png'
        self.spritePathClosedCoin = './Assets/Objects/door_close_coin.png'
        self.spritePathOpenEnemy = './Assets/Objects/door_open_enemies.png'
        self.spritePathClosedEnemy = './Assets/Objects/door_close_enemies.png'

        self.game = game
        self.spriteBaseSize = 16
        self.topoffset = 18
        self.xoffset = 19
        self.setProperties(properties)

        self.enemyDoor = self.have('enemy')
        self.coinDoor = self.have('coin')

        self.x, self.y, self.w, self.h = x, y, 32, 32
        self.startQTBoundaries(self.x, self.y, self.w, self.h)

        self.collide = True
        self.collectable = True
        self.collected = False
        self.collisionExecuted = False
        self.opened = True

        if self.enemyDoor:
            self.openSprite = SpriteSheet(
                pygame.image.load(self.spritePathOpenEnemy))
            self.closeSprite = SpriteSheet(
                pygame.image.load(self.spritePathClosedEnemy))
        elif self.coinDoor:
            self.openSprite = SpriteSheet(
                pygame.image.load(self.spritePathOpenCoin))
            self.closeSprite = SpriteSheet(
                pygame.image.load(self.spritePathClosedCoin))
        else:
            self.openSprite = SpriteSheet(
                pygame.image.load(self.spritePathOpen))
            self.closeSprite = SpriteSheet(
                pygame.image.load(self.spritePathClosed))

        self.openAnimation = SpriteAnimation(10, 5, False)
        self.openState = [
            self.openSprite.getimage(self.spriteBaseSize * x, 0,
                                     self.spriteBaseSize, self.spriteBaseSize)
            for x in range(self.openAnimation.framesQuantity)
        ]
        self.game.animationSystem.addAnimation(self.openAnimation)
Exemplo n.º 7
0
    def __init__(self, x, y, w, h, props, game):
        self.x, self.y, self.w, self.h = x, y, w, h
        self.cs = (-8, -12)
        self.co = (4, 12)
        self.killAnimationTime = 30
        self.spritePathPrefix = './Assets/Enemies/'
        self.setProperties(props)
        self.game = game
        self.spriteBaseSize = 16
        self.hurtAmount = 1
        self.mathUtil = MathFunctions()

        self.velX = 0
        self.velY = 0

        self.state = "NORMAL"
        self.movSpeed = 0.003

        self.startXPosition = self.x / 32
        self.startYPosition = self.y / 32
        self.endXPosition = self.x / 32
        self.endYPosition = self.y / 32
        if self.have('x'):
            self.endXPosition = int(self.get('x'))
        if self.have('y'):
            self.endYPosition = int(self.get('y'))

        self.movement = [
            self.startXPosition, self.startYPosition, self.endXPosition,
            self.endYPosition
        ]
        self.movementTimer = 0
        self.drop = None
        self.dropAdded = False

        if self.have('drop'):
            attr = self.get('drop').split('|')
            self.drop = QueueItem(attr[0], attr[1] + ':' + attr[2])

        # Idle State
        self.idleSprite = SpriteSheet(
            pygame.image.load(self.spritePathPrefix + 'slime_idle.png'))
        self.idleAnimation = SpriteAnimation(5, 10, True)
        self.idleState = [
            self.idleSprite.getimage(self.spriteBaseSize * x, 0,
                                     self.spriteBaseSize, self.spriteBaseSize)
            for x in range(self.idleAnimation.framesQuantity)
        ]
        self.game.animationSystem.addAnimation(self.idleAnimation)

        # Walk State
        self.walkSprite = SpriteSheet(
            pygame.image.load(self.spritePathPrefix + 'slime_walk.png'))
        self.walkAnimation = SpriteAnimation(2, 20, True)
        self.walkState = [
            self.walkSprite.getimage(self.spriteBaseSize * x, 0,
                                     self.spriteBaseSize, self.spriteBaseSize)
            for x in range(self.walkAnimation.framesQuantity)
        ]
        self.game.animationSystem.addAnimation(self.walkAnimation)

        # Kill State
        self.killSprite = SpriteSheet(
            pygame.image.load(self.spritePathPrefix + 'slime_kill.png'))
        self.killState = [
            self.killSprite.getimage(0, 0, self.spriteBaseSize,
                                     self.spriteBaseSize)
        ]