- @classmethod
- def image(cls, neighbors):
- 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, neighbors):
- 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 = "underground"
-
-class Tunnel(Tile):
-
- @classmethod
- def image(cls, neighbors):
- connections = len([x for x in neighbors if 'walk' in x['behaviour']])
- # simple cases
- if connections == 0:
- # return single point tunnel
- pass
- elif connections == 4:
- # crossroads
- pass
- elif connections == 3:
- # 3 point connector, rotated correctly
- pass
- elif connections == 1:
- # 1 point connector, roatated correctly
- pass
- elif connections == 2:
- # Need to distinguish pass-through or corner, and
- # rotate correctly
- pass
- cls.IMG = os.path.join('tunnel', 'tunnel_none')
- return super(Tunnel, cls).image(neighbors)
-