Source

Squish the Bugs / squishthebugs / map_0.py

Full commit
'''
Created: Aug 10, 2013
Last modified: Aug 12, 2013
@author Flaise Saffron
'''

def make(make_player, make_bug, make_grass, make_stone, make_boulder, make_tree, make_bush_0, make_bush_1, make_wood_floor, make_water, make_dirt):
	cursor = (0, 0, 0)
	
	def advance_row(a):
		nonlocal cursor
		cursor = (0, cursor[1], cursor[2] + 1)
	def advance_one():
		nonlocal cursor
		cursor = (cursor[0] + 1, cursor[1], cursor[2])
	def advance_layer(a):
		nonlocal cursor
		cursor = (0, cursor[1] + 1, 0)
		
	char_to_maker = {
		'P': make_player,
		'B': make_bug,
		'g': make_grass,
		's': make_stone,
		'R': make_boulder,
		'T': make_tree,
		'1': make_bush_0,
		'2': make_bush_1,
		'w': make_wood_floor,
		'~': make_water,
		'd': make_dirt,
		'\n': advance_row,
		'^': advance_layer,
		' ': lambda a: None
	}
	
	data = """
^




dd
dd
dd
dd
^




~~
~~
~~dd
~~dddds
^


    ss
dd
   
  dd
  R dd
      s
^
gggg
ggg
ssg ~~
  ggggs
  ggdd
   Pdd
    gds
      R
^
2RBdT11
 T ddd
ss d  d
  1   R
    TTs
     Bs
    2 s
^

B   ddg

   
      s
      s
      s
^
"""
	
	for char in data:
		char_to_maker[char](cursor)
		advance_one()