projects
/
koperkapel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Crudely hack tileset support back in
[koperkapel.git]
/
koperkapel
/
loaders
/
levelloader.py
diff --git
a/koperkapel/loaders/levelloader.py
b/koperkapel/loaders/levelloader.py
index 699b520c06884f3fd293212569aa8ca7dd99f0c4..544777c6aea5dfb60d001857b9769a4bf9920cb8 100644
(file)
--- a/
koperkapel/loaders/levelloader.py
+++ b/
koperkapel/loaders/levelloader.py
@@
-10,26
+10,28
@@
from pygame.transform import rotate
class Tile:
IMG = None
class Tile:
IMG = None
+ TILESET = None
@classmethod
def image(cls):
@classmethod
def image(cls):
- if cls.IMG is None:
+ if cls.IMG is None
or cls.TILESET is None
:
raise NotImplementedError()
raise NotImplementedError()
-
- return images.load(cls.IMG)
+ return images.load(os.path.join(cls.TILESET, cls.IMG))
class RandomizedTile(Tile):
IMGDIR = None
class RandomizedTile(Tile):
IMGDIR = None
- ROTATE = True
+ TILESET = None
+ ROTATE = None
@classmethod
def image(cls):
@classmethod
def image(cls):
- if cls.IMGDIR is None:
+ if cls.IMGDIR is None
or cls.TILESET is None
:
raise NotImplementedError()
raise NotImplementedError()
- imgdir = os.path.join(os.path.dirname(__file__), '..', 'images', cls.IMGDIR)
+ imgdir = os.path.join(os.path.dirname(__file__), '..', 'images',
+ cls.TILESET, cls.IMGDIR)
imgpath = 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))
+ img = images.load(os.path.join(cls.
TILESET, cls.
IMGDIR, imgpath))
if cls.ROTATE:
img = rotate(img, 90 * random.randint(0, 3))
if cls.ROTATE:
img = rotate(img, 90 * random.randint(0, 3))
@@
-66,6
+68,8
@@
class LevelLoader(ResourceLoader):
for row, row_data in enumerate(self._tiles):
if len(row_data) != self._width:
raise RuntimeError("Incorrect len for row %d" % row)
for row, row_data in enumerate(self._tiles):
if len(row_data) != self._width:
raise RuntimeError("Incorrect len for row %d" % row)
+ for tile in TILES.values():
+ tile.TILESET = self._tileset
self._load_tile_images()
return level_data
self._load_tile_images()
return level_data