- @classmethod
- def image(cls):
- if cls.IMG is None or cls.TILESET is None:
- raise NotImplementedError()
- return images.load(os.path.join(cls.TILESET, cls.IMG))
-
-class RandomizedTile(Tile):
- IMGDIR = None
- TILESET = None
- ROTATE = None
-
- @classmethod
- def image(cls):
- if cls.IMGDIR is None or cls.TILESET is None:
- raise NotImplementedError()
-
- imgdir = os.path.join(os.path.dirname(__file__), '..', 'images',
- cls.TILESET, cls.IMGDIR)
- imgpath = os.path.splitext(random.choice(os.listdir(imgdir)))[0]
- img = images.load(os.path.join(cls.TILESET, cls.IMGDIR, imgpath))
-
- if cls.ROTATE:
- img = rotate(img, 90 * random.randint(0, 3))
-
- return img
-
-class Floor(RandomizedTile):
- IMGDIR = "floor"
-
-class Wall(RandomizedTile):
- IMGDIR = "wall"
-
-class Underground(RandomizedTile):
- IMGDIR = "wall"
-
-class Tunnel(RandomizedTile):
- IMGDIR = "floor"