/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-29 01:54:19 UTC
  • Revision ID: josh@9ix.org-20130429015419-8ts0gwspqonsxkjb
Tags: compo
name the game

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
 
gate = ''
 
14
other = ''
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
 
33
45
    sel = CSSSelector('svg|rect[ink|label="transition"]', ns)
34
46
    for e in sel(t):
35
47
        x, y = float(e.get('x')), float(e.get('y'))
116
128
},
117
129
""" % (x,y,w,h)
118
130
 
 
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
    sel = CSSSelector('svg|rect[ink|label="boat"]', ns)
 
144
    for e in sel(t):
 
145
        x, y = float(e.get('x')), float(e.get('y'))
 
146
        #w, h = float(e.get('width')), float(e.get('height'))
 
147
 
 
148
        print """
 
149
Boat:new{
 
150
  x = %f, y = %f,
 
151
},
 
152
""" % (x,y)
 
153
 
119
154
    sel = CSSSelector('svg|rect[ink|label="troll"]', ns)
120
155
    for e in sel(t):
121
156
        x, y = float(e.get('x')), float(e.get('y'))
136
171
        x, y = float(e.get('x')), float(e.get('y'))
137
172
        w, h = float(e.get('width')), float(e.get('height'))
138
173
 
139
 
        gate = gate + """
 
174
        other = other + """
140
175
gateup = Fill:new{
141
176
  x = %f, y = %f,
142
177
  width = %f, height = %f,
150
185
        x, y = float(e.get('x')), float(e.get('y'))
151
186
        w, h = float(e.get('width')), float(e.get('height'))
152
187
 
153
 
        gate = gate + """
 
188
        other = other + """
154
189
gatedown = Fill:new{
155
190
  x = %f, y = %f,
156
191
  width = %f, height = %f,
159
194
}
160
195
""" % (x,y,w,h)
161
196
 
 
197
    sel = CSSSelector('svg|rect[ink|label="fairytarget"]', ns)
 
198
    for e in sel(t):
 
199
        x, y = float(e.get('x')), float(e.get('y'))
 
200
        w, h = float(e.get('width')), float(e.get('height'))
 
201
 
 
202
        other = other + """
 
203
fairytarget = Sprite:new{
 
204
  x = %f, y = %f,
 
205
  width = %f, height = %f,
 
206
  visible = false
 
207
}
 
208
""" % (x,y,w,h)
 
209
 
162
210
 
163
211
print '}'
164
212
 
165
 
print gate
 
213
print other