Commits

Westley Martínez  committed ccc09b9

Fix map loading bug.

  • Participants
  • Parent commits 9dce501
  • Tags 0.1.1

Comments (0)

Files changed (2)

         return {'map': self.map, 'tiles': self.tiles, 'width': self.width,
                 'height': self.height, 'paths': self.paths,
                 'vwidth': self.vwidth, 'vheight': self.vheight,
-                'tile_size': self.tile_size}
+                'tile_size': self.tile_size, '__tile_db': self.__tile_db,
+                '__next_index': self.__next_index}
 
     def set_structure(self, struct):
+        self.__tile_db = struct['__tile_db']
+        self.__next_index = struct['__next_index']
         self.map = struct['map']
         self.tiles = struct['tiles']
         self.width = struct['width']
         used = self.__tile_db.values()
         if not used:
             return 0
-        available = [x for x in range(len(self.__tile_db) + 1) if x not in used]
+        available = [x for x in range(len(self.__tile_db)+1) if x not in used]
         self.__next_index = min(available)
         return self.__next_index
 

File example.animap

-{"map": [[null, 0, null, null, null, 0, null, 1, null, null, null, 1, null, null, 2, 2, 2, null, null, null], [null, 0, null, null, null, 0, null, 1, 1, null, 1, 1, null, 2, null, null, null, null, null, null], [null, 0, null, 0, null, 0, null, 1, null, 1, null, 1, null, 2, null, null, null, null, null, null], [null, 0, null, 0, null, 0, null, 1, null, null, null, 1, null, 2, null, null, 2, 2, null, null], [null, null, 0, null, 0, null, null, 1, null, null, null, 1, null, 2, null, null, null, 2, null, null], [null, null, 0, null, 0, null, null, 1, null, null, null, 1, null, null, 2, 2, 2, null, null, null], [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]], "width": 20, "paths": ["data/pixmaps/tiles"], "tile_size": 32, "tiles": {"main_hill.gif_0": 2, "main_town.gif_0": 1, "main_swamp.gif_0": 6, "main_desert.gif_0": 4, "main_grass.gif_0": 0, "main_water.gif_0": 7, "main_forest.gif_0": 8, "main_mountain.gif_0": 5, "main_castle.gif_0": 3}, "height": 15, "vheight": 480, "vwidth": 640}
+{
+    "__next_index": 8,
+    "__tile_db": {
+        "main_castle.gif_0": 3,
+        "main_desert.gif_0": 4,
+        "main_forest.gif_0": 8,
+        "main_grass.gif_0": 0,
+        "main_hill.gif_0": 2,
+        "main_mountain.gif_0": 5,
+        "main_swamp.gif_0": 6,
+        "main_town.gif_0": 1,
+        "main_water.gif_0": 7
+    },
+    "height": 15,
+    "map": [
+        [
+            null,
+            0,
+            null,
+            null,
+            null,
+            0,
+            null,
+            1,
+            null,
+            null,
+            null,
+            1,
+            null,
+            null,
+            2,
+            2,
+            2,
+            null,
+            null,
+            null
+        ],
+        [
+            null,
+            0,
+            null,
+            null,
+            null,
+            0,
+            null,
+            1,
+            1,
+            null,
+            1,
+            1,
+            null,
+            2,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null
+        ],
+        [
+            null,
+            0,
+            null,
+            0,
+            null,
+            0,
+            null,
+            1,
+            null,
+            1,
+            null,
+            1,
+            null,
+            2,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null
+        ],
+        [
+            null,
+            0,
+            null,
+            0,
+            null,
+            0,
+            null,
+            1,
+            null,
+            null,
+            null,
+            1,
+            null,
+            2,
+            null,
+            null,
+            2,
+            2,
+            null,
+            null
+        ],
+        [
+            null,
+            null,
+            0,
+            null,
+            0,
+            null,
+            null,
+            1,
+            null,
+            null,
+            null,
+            1,
+            null,
+            2,
+            null,
+            null,
+            null,
+            2,
+            null,
+            null
+        ],
+        [
+            null,
+            null,
+            0,
+            null,
+            0,
+            null,
+            null,
+            1,
+            null,
+            null,
+            null,
+            1,
+            null,
+            null,
+            2,
+            2,
+            2,
+            null,
+            null,
+            null
+        ],
+        [
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null
+        ],
+        [
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3,
+            3
+        ],
+        [
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4,
+            4
+        ],
+        [
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5,
+            5
+        ],
+        [
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6,
+            6
+        ],
+        [
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1,
+            1
+        ],
+        [
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7,
+            7
+        ],
+        [
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0,
+            0
+        ],
+        [
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8,
+            8
+        ]
+    ],
+    "paths": [
+        "data/pixmaps/tiles"
+    ],
+    "tile_size": 32,
+    "tiles": {
+        "main_castle.gif_0": 3,
+        "main_desert.gif_0": 4,
+        "main_forest.gif_0": 8,
+        "main_grass.gif_0": 0,
+        "main_hill.gif_0": 2,
+        "main_mountain.gif_0": 5,
+        "main_swamp.gif_0": 6,
+        "main_town.gif_0": 1,
+        "main_water.gif_0": 7
+    },
+    "vheight": 480,
+    "vwidth": 640,
+    "width": 20
+}