/ld26

To get this branch, use:
bzr branch /bzr/ld26

« back to all changes in this revision

Viewing changes to svg_levels.py

  • Committer: Josh C
  • Date: 2013-04-28 23:55:40 UTC
  • Revision ID: josh@9ix.org-20130428235540-wamoh325zjypaf06
dragon flag special case

Show diffs side-by-side

added added

removed removed

11
11
ns = {'svg': 'http://www.w3.org/2000/svg',
12
12
      'ink': 'http://www.inkscape.org/namespaces/inkscape'}
13
13
 
14
 
other = ''
 
14
gate = ''
15
15
 
16
16
for svg in glob.glob('data/*.svg'):
17
17
    t = etree.parse(svg)
30
30
},
31
31
""" % (x,y,w,h)
32
32
 
33
 
    sel = CSSSelector('svg|rect[ink|label="maybedisplace"]', ns)
34
 
    for e in sel(t):
35
 
        x, y = float(e.get('x')), float(e.get('y'))
36
 
        w, h = float(e.get('width')), float(e.get('height'))
37
 
 
38
 
        print """
39
 
MaybeDisplacer:new{
40
 
  x = %f, y = %f,
41
 
  width = %f, height = %f
42
 
},
43
 
""" % (x,y,w,h)
44
 
 
45
33
    sel = CSSSelector('svg|rect[ink|label="transition"]', ns)
46
34
    for e in sel(t):
47
35
        x, y = float(e.get('x')), float(e.get('y'))
104
92
},
105
93
""" % (x,y,w,h)
106
94
 
107
 
    sel = CSSSelector('svg|rect[ink|label="fairy"]', ns)
108
 
    for e in sel(t):
109
 
        x, y = float(e.get('x')), float(e.get('y'))
110
 
        w, h = float(e.get('width')), float(e.get('height'))
111
 
 
112
 
        print """
113
 
Fairy:new{
114
 
  x = %f, y = %f,
115
 
  width = %f, height = %f,
116
 
},
117
 
""" % (x,y,w,h)
118
 
 
119
95
    sel = CSSSelector('svg|rect[ink|label="gatetrigger"]', ns)
120
96
    for e in sel(t):
121
97
        x, y = float(e.get('x')), float(e.get('y'))
128
104
},
129
105
""" % (x,y,w,h)
130
106
 
131
 
    sel = CSSSelector('svg|rect[ink|label="fairyactivator"]', ns)
132
 
    for e in sel(t):
133
 
        x, y = float(e.get('x')), float(e.get('y'))
134
 
        w, h = float(e.get('width')), float(e.get('height'))
135
 
 
136
 
        print """
137
 
FairyActivator:new{
138
 
  x = %f, y = %f,
139
 
  width = %f, height = %f,
140
 
},
141
 
""" % (x,y,w,h)
142
 
 
143
107
    sel = CSSSelector('svg|rect[ink|label="troll"]', ns)
144
108
    for e in sel(t):
145
109
        x, y = float(e.get('x')), float(e.get('y'))
160
124
        x, y = float(e.get('x')), float(e.get('y'))
161
125
        w, h = float(e.get('width')), float(e.get('height'))
162
126
 
163
 
        other = other + """
 
127
        gate = gate + """
164
128
gateup = Fill:new{
165
129
  x = %f, y = %f,
166
130
  width = %f, height = %f,
174
138
        x, y = float(e.get('x')), float(e.get('y'))
175
139
        w, h = float(e.get('width')), float(e.get('height'))
176
140
 
177
 
        other = other + """
 
141
        gate = gate + """
178
142
gatedown = Fill:new{
179
143
  x = %f, y = %f,
180
144
  width = %f, height = %f,
183
147
}
184
148
""" % (x,y,w,h)
185
149
 
186
 
    sel = CSSSelector('svg|rect[ink|label="fairytarget"]', ns)
187
 
    for e in sel(t):
188
 
        x, y = float(e.get('x')), float(e.get('y'))
189
 
        w, h = float(e.get('width')), float(e.get('height'))
190
 
 
191
 
        other = other + """
192
 
fairytarget = Sprite:new{
193
 
  x = %f, y = %f,
194
 
  width = %f, height = %f,
195
 
  visible = false
196
 
}
197
 
""" % (x,y,w,h)
198
 
 
199
150
 
200
151
print '}'
201
152
 
202
 
print other
 
153
print gate