From: adrianna Date: Wed, 2 Mar 2016 22:21:12 +0000 (+0200) Subject: moar randomness X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=815ef3fcfed6bb2e23d5d61c02542535f2d3c303;p=koperkapel.git moar randomness --- 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"