Example #1
0
class Key:
    def __init__(self, keytype, pos):
        self.key_type = keytype
        self.pos = pos
        frames = 1
        if self.key_type == KeyEnum.SILVER or self.key_type == KeyEnum.GOLD:
            frames = 32

        self.sprite = AnimatedSprite(KeySprites[self.key_type.value], frames)
        self.sprite.set_location(pos)

    def draw(self,screen,camera):
        self.sprite.draw(screen, camera)

    def update(self, deltatime):
        self.sprite.update(deltatime)

    def save(self, file):
        file.write(str(self.key_type.value))
        file.write('\n')
        file.write(str(self.pos[0]))
        file.write('\n')
        file.write(str(self.pos[1]))
        file.write('\n')

    @staticmethod
    def load(file, level):
        key_type = int(file.readline())
        posx = int(file.readline())
        posy = int(file.readline())
        pos = (posx, posy)
        return (Key(KeyEnum(key_type),pos))
Example #2
0
class WeaponItem:
    def __init__(self, weapon_type, pos):
        self.sprite = AnimatedSprite(WeaponSprites[weapon_type.value], 1)
        self.sprite.set_location(pos)
        self.weapon_type = weapon_type
        self.pos = pos

    def draw(self,screen,camera):
        self.sprite.draw(screen, camera)

    def update(self, deltatime):
        self.sprite.update(deltatime)

    def save(self, file):
        file.write(str(self.weapon_type.value))
        file.write('\n')
        file.write(str(self.pos[0]))
        file.write('\n')
        file.write(str(self.pos[1]))
        file.write('\n')

    @staticmethod
    def load(file, level):
        weapon_type = int(file.readline())
        posx = int(file.readline())
        posy = int(file.readline())
        pos = (posx, posy)
        return (WeaponItem(WeaponEnum(weapon_type), pos))
Example #3
0
class Lock:
    def __init__(self, locktype, pos):
        self.lock_type = locktype
        self.pos = pos
        frames = 1
        if self.lock_type == KeyEnum.SILVER or self.lock_type == KeyEnum.GOLD:
            frames = 32

        self.sprite = AnimatedSprite(LockSprites[self.lock_type.value], frames)
        self.sprite.set_location(pos)

    def draw(self, screen, camera):
        self.sprite.draw(screen, camera)

    def update(self, deltatime):
        self.sprite.update(deltatime)

    def save(self, file):
        file.write(str(self.lock_type.value))
        file.write('\n')
        file.write(str(self.pos[0]))
        file.write('\n')
        file.write(str(self.pos[1]))
        file.write('\n')

    @staticmethod
    def load(file, level):
        key_type = int(file.readline())
        posx = int(file.readline())
        posy = int(file.readline())
        pos = (posx,posy)
        return (Lock(KeyEnum(key_type),pos))
Example #4
0
class Powerup:
    def __init__(self, spriteenum, frames, pos):
        self.sprite = AnimatedSprite(spriteenum, frames)
        self.sprite.set_location(pos)
        self.buff = None

    def draw(self, screen, camera):
        self.sprite.draw(screen, camera)

    def update(self, deltatime):
        self.sprite.update(deltatime)
Example #5
0
class Powerup:
    def __init__(self, spriteenum, frames, pos):
        self.sprite = AnimatedSprite(spriteenum, frames)
        self.sprite.set_location(pos)
        self.buff = None

    def draw(self,screen,camera):
        self.sprite.draw(screen, camera)

    def update(self, deltatime):
        self.sprite.update(deltatime)