from pgzero.loaders import images, ResourceLoader
import os
import random
+from pygame.transform import rotate
class Tile:
IMG = None
class RandomizedTile(Tile):
IMGDIR = None
+ ROTATE = True
@classmethod
def image(cls):
raise NotImplementedError()
imgdir = os.path.join(os.path.dirname(__file__), '..', 'images', cls.IMGDIR)
- img = os.path.splitext(random.choice(os.listdir(imgdir)))[0]
+ imgpath = os.path.splitext(random.choice(os.listdir(imgdir)))[0]
+ img = images.load(os.path.join(cls.IMGDIR, imgpath))
- return images.load(os.path.join(cls.IMGDIR, img))
+ if cls.ROTATE:
+ img = rotate(img, 90 * random.randint(0, 3))
+
+ return img
class Floor(RandomizedTile):
IMGDIR = "floor"