Add placeholder underground images. Start work on proper tunnel image loading
authorNeil <neil@dip.sun.ac.za>
Thu, 3 Mar 2016 10:23:28 +0000 (12:23 +0200)
committerNeil <neil@dip.sun.ac.za>
Thu, 3 Mar 2016 10:23:28 +0000 (12:23 +0200)
21 files changed:
koperkapel/images/Makefile
koperkapel/images/bunker/floor/floor_1.png
koperkapel/images/bunker/floor/floor_2.png
koperkapel/images/bunker/floor/floor_3.png
koperkapel/images/bunker/floor/floor_4.png
koperkapel/images/bunker/tunnel/tunnel_none.png [new file with mode: 0644]
koperkapel/images/bunker/underground/underground_1.png [new file with mode: 0644]
koperkapel/images/bunker/underground/underground_2.png [new file with mode: 0644]
koperkapel/images/bunker/underground/underground_3.png [new file with mode: 0644]
koperkapel/images/bunker/underground/underground_4.png [new file with mode: 0644]
koperkapel/images/bunker/wall/wall_1.png
koperkapel/images/bunker/wall/wall_2.png
koperkapel/images/bunker/wall/wall_3.png
koperkapel/images/bunker/wall/wall_4.png
koperkapel/loaders/levelloader.py
sources/bitmap/tunnel/tunnel_base.xcf [new file with mode: 0644]
sources/bitmap/tunnel/tunnel_none.png [new file with mode: 0644]
sources/bitmap/underground/underground_1.png [new file with mode: 0644]
sources/bitmap/underground/underground_2.png [new file with mode: 0644]
sources/bitmap/underground/underground_3.png [new file with mode: 0644]
sources/bitmap/underground/underground_4.png [new file with mode: 0644]

index d55f9119cb69a372cafbe7bae72c7037884383cd..d5aa40507df3b5e4ef0cda5163c951d714e63a6e 100644 (file)
@@ -8,7 +8,7 @@ TILE_PNGS=$(patsubst $(VPATH)/vector/%.svg, %.png, $(TILE_SVGS))
 
 # Bitmap tiles
 
-BTILE_DIRS=wall floor
+BTILE_DIRS=wall floor tunnel underground
 BTILE_SRC=$(shell find $(patsubst %, $(VPATH)/bitmap/%, $(BTILE_DIRS)) -name "*.png")
 BTILE_PNGS=$(patsubst $(VPATH)/bitmap/%, %, $(BTILE_SRC))
 
@@ -55,8 +55,8 @@ $(foreach simpledir,$(SIMPLE_DIRS),$(eval $(call simple,$(simpledir))))
 
 define btile
 $(1)/%.png: bitmap/$(1)/%.png
-       @mkdir -p `dirname $$@`
-       @convert $$< -resize 64x64 $$@
+       @mkdir -p `dirname bunker/$$@`
+       @convert $$< -resize 64x64 bunker/$$@
 endef
 
 $(foreach tiledir,$(BTILE_DIRS),$(eval $(call btile,$(tiledir))))
index 25a47ce612593b5afc145ae667b262d3d6c59517..400ca072f2f5768481b1d8bedb4022e0b21df833 100644 (file)
Binary files a/koperkapel/images/bunker/floor/floor_1.png and b/koperkapel/images/bunker/floor/floor_1.png differ
index 8e03544ae3bfb9550bed3e6fa90549b0a019152a..4e51dd47ea426291bbb247bfd8a47e3e0845f610 100644 (file)
Binary files a/koperkapel/images/bunker/floor/floor_2.png and b/koperkapel/images/bunker/floor/floor_2.png differ
index 71bbb731c4a55ee0b8fb30e0c119c05a315beb7d..31b47a8c44fc5fd2a4396fd906fffad38482263d 100644 (file)
Binary files a/koperkapel/images/bunker/floor/floor_3.png and b/koperkapel/images/bunker/floor/floor_3.png differ
index dd87cb4ce5048286bbb63b524fadd6e1d7c4d7ab..8c4958e56403758b1eeb3ed33a627fdec458b6f1 100644 (file)
Binary files a/koperkapel/images/bunker/floor/floor_4.png and b/koperkapel/images/bunker/floor/floor_4.png differ
diff --git a/koperkapel/images/bunker/tunnel/tunnel_none.png b/koperkapel/images/bunker/tunnel/tunnel_none.png
new file mode 100644 (file)
index 0000000..dcb04b4
Binary files /dev/null and b/koperkapel/images/bunker/tunnel/tunnel_none.png differ
diff --git a/koperkapel/images/bunker/underground/underground_1.png b/koperkapel/images/bunker/underground/underground_1.png
new file mode 100644 (file)
index 0000000..23659b1
Binary files /dev/null and b/koperkapel/images/bunker/underground/underground_1.png differ
diff --git a/koperkapel/images/bunker/underground/underground_2.png b/koperkapel/images/bunker/underground/underground_2.png
new file mode 100644 (file)
index 0000000..43d294a
Binary files /dev/null and b/koperkapel/images/bunker/underground/underground_2.png differ
diff --git a/koperkapel/images/bunker/underground/underground_3.png b/koperkapel/images/bunker/underground/underground_3.png
new file mode 100644 (file)
index 0000000..99678c0
Binary files /dev/null and b/koperkapel/images/bunker/underground/underground_3.png differ
diff --git a/koperkapel/images/bunker/underground/underground_4.png b/koperkapel/images/bunker/underground/underground_4.png
new file mode 100644 (file)
index 0000000..05c0093
Binary files /dev/null and b/koperkapel/images/bunker/underground/underground_4.png differ
index e3516c4296bfe0eb7697a2793fccf1344bf04e6a..8cc0ee8e60b1e89db16016b9944c779c2317ae78 100644 (file)
Binary files a/koperkapel/images/bunker/wall/wall_1.png and b/koperkapel/images/bunker/wall/wall_1.png differ
index cd7fb189d002579652411040b94833fb6eae5d77..d5406deac026d10863e3e6b9c2c29599265baba6 100644 (file)
Binary files a/koperkapel/images/bunker/wall/wall_2.png and b/koperkapel/images/bunker/wall/wall_2.png differ
index 520bb86a9bd44c37bc7b30d282666ebaa10aab69..9fb20b4f7840cb86053919d8059ea5e946652398 100644 (file)
Binary files a/koperkapel/images/bunker/wall/wall_3.png and b/koperkapel/images/bunker/wall/wall_3.png differ
index 4a5fbb41f87f08d967ac03c9d91e407f2cef77b6..aed6bad03a3a67c260d9b1c6f2d09bcadc7f175b 100644 (file)
Binary files a/koperkapel/images/bunker/wall/wall_4.png and b/koperkapel/images/bunker/wall/wall_4.png differ
index a8aaa376efba9be55b7af1a7f7c70fab8ef8df18..6820b157598ebf42edefde880791327655c4035b 100644 (file)
@@ -13,7 +13,7 @@ class Tile:
     TILESET = None
 
     @classmethod
-    def image(cls):
+    def image(cls, neighbors):
         if cls.IMG is None or cls.TILESET is None:
             raise NotImplementedError()
         return images.load(os.path.join(cls.TILESET, cls.IMG))
@@ -24,7 +24,7 @@ class RandomizedTile(Tile):
     ROTATE = None
 
     @classmethod
-    def image(cls):
+    def image(cls, neighbors):
         if cls.IMGDIR is None or cls.TILESET is None:
             raise NotImplementedError()
 
@@ -45,10 +45,33 @@ class Wall(RandomizedTile):
     IMGDIR = "wall"
 
 class Underground(RandomizedTile):
-    IMGDIR = "wall"
+    IMGDIR = "underground"
 
-class Tunnel(RandomizedTile):
-    IMGDIR = "floor"
+class Tunnel(Tile):
+
+    @classmethod
+    def image(cls, neighbors):
+        connections = len([x for x in neighbors if 'walk' in x['behaviour']])
+        # simple cases
+        if connections == 0:
+            # return single point tunnel
+            pass
+        elif connections == 4:
+            # crossroads
+            pass
+        elif connections == 3:
+            # 3 point connector, rotated correctly
+            pass
+        elif connections == 1:
+            # 1 point connector, roatated correctly
+            pass
+        elif connections == 2:
+            # Need to distinguish pass-through or corner, and
+            # rotate correctly
+            pass
+        cls.IMG = os.path.join('tunnel', 'tunnel_none')
+        return super(Tunnel, cls).image(neighbors)
+        
 
 TILES = {
     "cwall": Wall, # rename this everywhere
@@ -83,10 +106,21 @@ class LevelLoader(ResourceLoader):
 
     def _load_tile_images(self):
         """Load all the tile images"""
-        for row_data in self._tiles:
-            for tile in row_data:
+        height = len(self._tiles)
+        width = len(self._tiles[0])
+        for y, row_data in enumerate(self._tiles):
+            for x, tile in enumerate(row_data):
+                # simplist case
+                # 4 -connected neighbors
+                neighborhood = [self._tiles[y][x-1] if x > 0 else None,
+                                self._tiles[y][x+1] if x < width - 1 else None,
+                                self._tiles[y-1][x] if y > 0 else None,
+                                self._tiles[y+1][x] if y < height- 1 else None,
+                               ]
                 for layer in ['floor', 'tunnels']:
-                    tile['%s image' % layer] = TILES[tile[layer]['base']].image()
+                    neighbors = [x[layer] if x else None for x in neighborhood]
+                    tile['%s image' % layer] = \
+                            TILES[tile[layer]['base']].image(neighbors)
 
 
 levels = LevelLoader('levels')
diff --git a/sources/bitmap/tunnel/tunnel_base.xcf b/sources/bitmap/tunnel/tunnel_base.xcf
new file mode 100644 (file)
index 0000000..7c1181b
Binary files /dev/null and b/sources/bitmap/tunnel/tunnel_base.xcf differ
diff --git a/sources/bitmap/tunnel/tunnel_none.png b/sources/bitmap/tunnel/tunnel_none.png
new file mode 100644 (file)
index 0000000..677e8b5
Binary files /dev/null and b/sources/bitmap/tunnel/tunnel_none.png differ
diff --git a/sources/bitmap/underground/underground_1.png b/sources/bitmap/underground/underground_1.png
new file mode 100644 (file)
index 0000000..4439f27
Binary files /dev/null and b/sources/bitmap/underground/underground_1.png differ
diff --git a/sources/bitmap/underground/underground_2.png b/sources/bitmap/underground/underground_2.png
new file mode 100644 (file)
index 0000000..c3fbb93
Binary files /dev/null and b/sources/bitmap/underground/underground_2.png differ
diff --git a/sources/bitmap/underground/underground_3.png b/sources/bitmap/underground/underground_3.png
new file mode 100644 (file)
index 0000000..8bf22b8
Binary files /dev/null and b/sources/bitmap/underground/underground_3.png differ
diff --git a/sources/bitmap/underground/underground_4.png b/sources/bitmap/underground/underground_4.png
new file mode 100644 (file)
index 0000000..619f92c
Binary files /dev/null and b/sources/bitmap/underground/underground_4.png differ