Code: Alles auswählen
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Generate the playingfield
"""
#~Imports
import cPickle as pickle
import random
#~Define arena
height_rows=15
width_cols=15
#~Variables
object_map = {5: 'baum1', 1: 'baum2', 7: 'baum3'}
rows = []
for y in range(height_rows):
col = []
for x in range(width_cols):
number = random.randint(1, 10)
name = object_map.get(number, 'grass')
col.append({"tile" : "/gametiles/%s.png" % name, "action" : None, "x" :
x, "y": y})
rows.append(col)
for row in rows:
for col in row:
print col
name = raw_input("mapname: ")
pickle.dump(rows, open("../maps/" + name + ".sav", "wb" ) )
print "fertig"