X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=koperkapel%2Floaders%2Flevelloader.py;h=ff18fc7b8e0548678dc172dd65db893fe33853fc;hb=815ef3fcfed6bb2e23d5d61c02542535f2d3c303;hp=640d9b168ada4e59073559058cb8654d72492fb5;hpb=bd7c8b7218aa80962ecdb3e8d3c0216aa3d40c1e;p=koperkapel.git diff --git a/koperkapel/loaders/levelloader.py b/koperkapel/loaders/levelloader.py index 640d9b1..ff18fc7 100644 --- a/koperkapel/loaders/levelloader.py +++ b/koperkapel/loaders/levelloader.py @@ -5,6 +5,7 @@ import json from pgzero.loaders import images, ResourceLoader import os import random +from pygame.transform import rotate class Tile: IMG = None @@ -18,6 +19,7 @@ class Tile: class RandomizedTile(Tile): IMGDIR = None + ROTATE = True @classmethod def image(cls): @@ -25,9 +27,13 @@ class RandomizedTile(Tile): 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"