import random
import math
+import json
+import os
i = random.randint(0,100)
+ATTRIBUTE_MAP = {
+ '#': {'base': 'cwall',
+ 'behaviour': [],
+ },
+ ' ': {'base': 'floor',
+ 'behaviour': ['walk', 'fly'],
+ },
+}
+
+
class LevelGenerator:
width = 0
height = 0
file.write(''.join(l))
file.write('\n')
file.close()
+ self._to_json()
for l in self.regions:
print(l)
+ def _to_json(self):
+ level = {}
+ level['tiles'] = []
+ for l in self.map:
+ row = []
+ for t in l:
+ row.append(ATTRIBUTE_MAP[t])
+ level['tiles'].append(row)
+ name = os.path.join(os.path.dirname(__file__), '..', 'levels', 'map.json')
+ # FIXME: Do a lot better here
+ # Crude hack so the level is written into the levels folder
+ f = open(name, 'w')
+ json.dump(level, f)
+ f.close()
+
if __name__ == '__main__':
while True: