diff options
Diffstat (limited to '')
-rw-r--r-- | src/mapdata.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/mapdata.py b/src/mapdata.py index 3938047..f8ededd 100644 --- a/src/mapdata.py +++ b/src/mapdata.py @@ -14,7 +14,7 @@ class KPObject(object): self.qtItem = None def updateCache(self): - self.cache = KP.map.tilesets[self.tileset].objects[self.kind].render(self.size) + self.cache = KP.map.loadedTilesets[self.tileset].objects[self.kind].render(self.size) class KPLayer(object): @@ -41,22 +41,24 @@ class KPLayer(object): y1, y2 = MAP_SIZE_IN_TILES[1] - 1, 0 for obj in self.objects: - pos, size = obj.position, obj.size + x, y = obj.position + w, h = obj.size + right, bottom = (x+w-1), (y+h-1) - if pos[0] < x1: - x1 = pos[0] - if pos[1] < y1: - y1 = pos[1] - if (pos[0] + size[0]) > x2: - x2 = pos[0] + size[0] - if (pos[1] + size[1]) > y2: - y2 = pos[1] + size[1] + if x < x1: + x1 = x + if y < y1: + y1 = y + if right > x2: + x2 = right + if bottom > y2: + y2 = bottom # create the cache # I was going to just resize it, but setting every tile to -1 # in Python would probably be slower than creating a new one ... - size = (x2 - x1, y2 - y1) + size = (x2 - x1 + 1, y2 - y1 + 1) width, height = size cache = [[-1 for i in xrange(width)] for j in xrange(height)] @@ -118,7 +120,7 @@ class KPMap(object): def __init__(self): self.nextLayerNumber = 1 - self.layers = [self.createNewLayer() for x in range(4)] + self.layers = [self.createNewLayer('Test') for x in range(4)] self.layerModel = KPMap.LayerModel(self.layers) self.nodes = [] self.paths = [] @@ -189,10 +191,11 @@ class KPMap(object): return False - def createNewLayer(self): + def createNewLayer(self, tilesetName): layer = KPLayer() layer.name = "Layer %d" % self.nextLayerNumber self.nextLayerNumber += 1 + layer.tileset = tilesetName return layer def appendLayer(self, layer): |