Example #1
0
    def load_tileset(self):
        pyglet.resource.reindex()
        img = self.game.load_image(self.mapdata['tileset'])
        pixelate(img)
        scale = float(self.tilesize) / img.width * 16
        grid = pyglet.image.ImageGrid(img, 16, 16)
        map(pixelate, grid)
        self.tileset = [grid[(15-row)*16 + col] for row in range(16) for col in range(16)]

        for row, cols in enumerate(self.mapdata['map']):
            for col, value in enumerate(cols):
                tile = self.tiles[row, col] = Tile(self, row, col, value)
                if tile.is_wall:
                    self.lightmap.set_wall(col, row)
Example #2
0
 def make_sprite(self):
     img  = self.game.load_image('smoke.png')
     grid = list(pyglet.image.ImageGrid(img, 1, 8))
     [(pixelate(g), center_image(g)) for g in grid]
     ani = Animation.from_image_sequence(grid, 0.1, loop=False)
     sprite = pyglet.sprite.Sprite(ani, batch=self.game.effect_batch)
     sprite.position = map(int, self.position)
     sprite.scale = 2
     return sprite
Example #3
0
 def make_sprite(self):
     img  = self.game.load_image('firebolt.png')
     grid = list(pyglet.image.ImageGrid(img, 1, 5))
     [(pixelate(g), center_image(g)) for g in grid]
     ani = Animation.from_image_sequence(grid, 0.05)
     sprite = pyglet.sprite.Sprite(ani, batch=self.game.object_batch)
     sprite.position = map(int, self.position)
     sprite.rotation = self.rotation
     sprite.scale = 2
     return sprite
Example #4
0
    def load_textures(self):
        img = self.game.load_image('player.png')
        grid = pyglet.image.ImageGrid(img, 4, 4)
        for img in grid:
            pixelate(img)
            img.width  *= 2
            img.height *= 2
            center_image(img, 0.5, 0.3)

        self.ani_running = {}
        self.ani_standing = {}
        for row, name in enumerate(('up','right','left','down')):
            ani_run   = [grid[row*4+col] for col in (1,2,3,2)]
            img_stand = grid[row*4+0]
            self.ani_running[name] = Animation.from_image_sequence(ani_run, 0.15)
            self.ani_standing[name] = img_stand

        self.sprite = pyglet.sprite.Sprite(self.ani_standing['down'], batch=self.game.object_batch)
        self.sprite.position = self.position
        self.moves = False
Example #5
0
 def make_sprite(self):
     img  = self.game.load_image('crater.png')
     pixelate(img)
     center_image(img)
     sprite = pyglet.sprite.Sprite(img, batch=self.game.decal_batch)
     return sprite