Exemple #1
0
def calcFrameSize(filename, frames, directions):
    """
    load the images for the animation and set the size of each frame
    """

    width, height = res.loadImage(filename, 0, 0, 1).get_size()
    return (width / frames, height / directions)
Exemple #2
0
def calcFrameSize(filename, frames, directions):
    """
    load the images for the animation and set the size of each frame
    """

    width, height = res.loadImage(filename, 0,0,1).get_size()
    return (width / frames, height / directions)
Exemple #3
0
    def load(self, force=False):
        """
        load the images for use with pygame
        """

        if not self.images == [] and not force:
            return

        image = res.loadImage(self.filename, 0, 0, 1)

        iw, ih = image.get_size()
        tw = iw / self.real_frames
        th = ih / self.directions
        self.images = [None] * (self.directions * self.real_frames)
      
        d = 0
        for y in range(0, ih, th):
            #if d == ih/th: d = 0
            for x in range(0, iw, tw):
                try:
                    frame = image.subsurface((x, y, tw, th))
                except ValueError as e:
                    raise ValueError, self.filename
                self.images[(x/tw)+d*self.real_frames] = frame
            d += 1

        if isinstance(self.timing, int):
            self.timing = [self.timing] * self.frames

        elif self.timing == None:
            self.timing = [200] * self.frames
Exemple #4
0
    def __init__(self, filename, hollow=False):
        self.hollow = hollow

        image = res.loadImage(filename, colorkey=True)
        iw, self.th = image.get_size()
        self.tw = iw / 9
        names = "nw ne sw se n e s w c".split()
        tiles = [image.subsurface((i * self.tw, 0, self.tw, self.th)) for i in range(9)]

        if self.hollow:
            ck = tiles[8].get_at((0, 0))
            [t.set_colorkey(ck, RLEACCEL) for t in tiles]

        self.tiles = dict(zip(names, tiles))
        self.background = self.tiles["c"].get_at((0, 0))
Exemple #5
0
    def load(self):
        """
        load the images for use with pygame
        """

        image = res.loadImage(self.filename, 0, 0, 1)
      
        if self.tile:
            x, y = self.tile
            x *= self.size[0]
            y *= self.size[1]
            ck = image.get_colorkey()
            self.image = pygame.Surface(self.size)
            self.image.blit(image,(0,0),area=(x,y, self.size[0], self.size[1]))
            image.set_colorkey(ck, pygame.RELACCEL) 

        else:
            self.image = image
Exemple #6
0
    def load(self):
        """
        load the images for use with pygame
        TODO: this is super hackish.
        """

        image = res.loadImage(self.filename, 0, 1)
      
        if self.tile:
            x, y = self.tile
            x *= self.size[0]
            y *= self.size[1]
            self.image = pygame.Surface(self.size)
            self.image.blit(image,(0,0),area=(x,y, self.size[0], self.size[1]))
            self.image.set_colorkey(self.image.get_at((0,0)))
 
        else:
            self.image = image

        self.frames = [self.image]
Exemple #7
0
    def load(self):
        """
        load the images for use with pygame
        """

        image = res.loadImage(self.filename, 0, 1)
        iw, ih = image.get_size()
        tw = iw / self.real_frames
        th = ih / self.directions
        self.images = [None] * (self.directions * self.real_frames)
       
        d = 2
        for y in range(0, ih, th):
            d += 1
            if d == ih/th: d = 0
            for x in range(0, iw, tw):
                frame = image.subsurface((x, y, tw, th))
                self.images[(x/tw)+d*self.real_frames] = frame

        if isinstance(self.timing, int):
            self.timing = [self.timing] * self.frames

        elif self.timing == None:
            self.timing = [200] * self.frames