예제 #1
0
    def __init__(self, **kwargs):
        # get location of sprites for this animation
        self.path = kwargs.get('path', None)

        # if not throw error
        if not self.path:
            print("Error: Need path to location of player_sprites!")
            sys.exit(0)

        self.animation_images = loadSpriteImages(self.path['path'])
        self.size = kwargs.get("resize", None)

        # container for all the pygame images
        self.sprites = {}

        # load images and "convert" them. (see link at top for explanation)
        for anim, imglist in self.animation_images.items():
            self.sprites[anim] = []
            for img in imglist:
                if self.size == None:
                    self.sprites[anim].append(pygame.image.load(img))
                else:
                    im = pygame.image.load(img)
                    frame = pygame.sprite.Sprite()
                    frame.image = pygame.transform.scale(
                        im, (self.size[0], self.size[1]))
                    self.sprites[anim].append(frame.image)
예제 #2
0
    def __init__(self, **kwargs):
        # get location of sprites for this animation
        self.path = kwargs.get('path', None)

        # if not throw error
        if not self.path:
            print("Error: Need path to location of player_sprites!")
            sys.exit(0)

        self.animation_images = loadSpriteImages(self.path['path'])

        # container for all the pygame images
        self.sprites = {}

        # load images and "convert" them. (see link at top for explanation)
        for anim, imglist in self.animation_images.items():
            self.sprites[anim] = []
            for img in imglist:
                self.sprites[anim].append(pygame.image.load(img))
예제 #3
0
    def __init__(self, **kwargs):
        """
        Params:
            path <string> : Path to your sprite images
            size <tuple>  : New size for your sprite frames - (new_width,new_height)
        """
        # get location of sprites for this animation
        self.path = kwargs.get('path', None)

        # if not throw error
        if not self.path:
            print("Error: Need path to location of player_sprites!")
            sys.exit(0)

        # Load the images for our sprite
        self.animation_images = loadSpriteImages(self.path['path'])

        # get a new size if one is passed in
        self.size = kwargs.get("resize", None)

        # container for all the pygame images
        self.sprites = {}

        # load images and "convert" them. (see link at top for explanation)
        for anim, imglist in self.animation_images.items():
            self.sprites[anim] = []
            for img in imglist:
                # no size passed in, so just create sprites
                if self.size == None:
                    self.sprites[anim].append(pygame.image.load(img))
                else:
                    # load a resize image by scaling them
                    im = pygame.image.load(img)
                    frame = pygame.sprite.Sprite()
                    frame.image = pygame.transform.scale(
                        im, (self.size[0], self.size[1]))
                    self.sprites[anim].append(frame.image)