Stuff
authorDavid.Sharpe <david.sharpe@Daves-MBP.lan>
Sat, 5 Mar 2016 15:50:19 +0000 (17:50 +0200)
committerDavid.Sharpe <david.sharpe@Daves-MBP.lan>
Sat, 5 Mar 2016 15:50:19 +0000 (17:50 +0200)
koperkapel/levels/l2
koperkapel/levels/level_converter.py

index e106e8206f6360023f79f95048e1d50ba77b3350..bbfed4a23ebf9b5f3db8af9ad60701867078d44e 100644 (file)
@@ -1,4 +1,21 @@
-wwww
-wffw
-wffw
-wwww
\ No newline at end of file
+wwwwwwwwwwwwwwwwwwwwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wsfffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wwwwwwwwwwwwwwwwwwwwwwwwwwwww
\ No newline at end of file
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3f195a240f77a8bfddc6e6673650b17294e81472 100644 (file)
@@ -0,0 +1,99 @@
+import os
+import json
+
+ATTRIBUTE_MAP = {
+    ' ': {'floor': {'base': 'floor',
+                    'behaviour': ['walk', 'fly'],
+                    },
+          },
+    'w': {'floor': {'base': 'floor',
+                    'behaviour': [],
+                    },
+          },
+    'o': {'tunnels': {'base': 'underground',
+                      'behaviour': [],
+                      }
+          },
+    't': {'tunnels': {'base': 'underground',
+                      'behaviour': [],
+                      }
+          },
+    '-': {'tunnels': {'base': 'tunnel',
+                      'behaviour': ['walk', ],
+                      },
+          },
+    'f': {'floor': {'base': 'floor',
+                    'behaviour': ['walk', 'fly'],
+                    },
+          },
+    'd': {'floor': {'base': 'floor',
+                    'behaviour': ['walk', 'fly'],
+                    },
+          },
+    'g': {'floor': {'base': 'floor',
+                    'behaviour': ['walk', 'fly'],
+                    },
+          },
+    'k': {'floor': {'base': 'floor',
+                    'behaviour': ['walk', 'fly'],
+                    },
+          },
+    's': {'floor': {'base': 'floor',
+                    'behaviour': ['walk', 'fly'],
+                    },
+          },
+}
+
+
+class level_generator:
+
+    def __init__(self):
+
+        pass
+
+    def convert(self, passage_file, tunnel_file):
+        print('Make level')
+        with open(passage_file) as passages:
+            with open(tunnel_file) as tunnels:
+                p = []
+                for a in passages:
+                    r = []
+                    for aa in a:
+                        r.append(aa)
+                    p.append(r)
+                t = []
+                for a in tunnels:
+                    r = []
+                    for aa in a:
+                        r.append(aa)
+                    t.append(r)
+                level = {}
+                level['tileset'] = 'bunker'
+                level['tiles'] = []
+                level['starting pos'] = []
+                level['door_info'] = []
+
+
+
+                for l, lu in zip(p, t):
+                    row = []
+                    for t1, t2 in zip(l, lu):
+                        if t1 != '\n' and t2 != '\n':
+                            print(t1, t2)
+                            tile = ATTRIBUTE_MAP[t1].copy()
+                            tile.update(ATTRIBUTE_MAP[t2])
+                            row.append(tile)
+                        if t1 == 's':
+                            level['starting pos'] = [len(level) - 1, len(row) - 1]
+                        # if t2 == 'd'
+                    level['tiles'].append(row)
+                # Crude hack so the level is written into the levels folder
+                name = os.path.join(os.path.dirname(__file__), '..', 'levels', 'map.json')
+                f = open(name, 'w')
+                json.dump(level, f, indent=3)
+                f.close()
+
+
+if __name__ == '__main__':
+    l = level_generator()
+    l.convert('l2', 't2')