From: David.Sharpe Date: Sat, 5 Mar 2016 15:50:19 +0000 (+0200) Subject: Stuff X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=9fcf0bb041dcc6d34e54d15cd3c8cf037059476d;p=koperkapel.git Stuff --- diff --git a/koperkapel/levels/l2 b/koperkapel/levels/l2 index e106e82..bbfed4a 100644 --- a/koperkapel/levels/l2 +++ b/koperkapel/levels/l2 @@ -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 diff --git a/koperkapel/levels/level_converter.py b/koperkapel/levels/level_converter.py index e69de29..3f195a2 100644 --- a/koperkapel/levels/level_converter.py +++ b/koperkapel/levels/level_converter.py @@ -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')