Personaly I feel that loading levels from Inkscape-generated SVG is very simple.
Moreover while saving selecting "Inkscape SVG" instead of "Plain SVG",
Inkscape adds some very interesting arguments with its namespace.
For exemple to get circles I use:
Code: Select all
cx = get_val "sodipodi:cx"
cy = get_val "sodipodi:cy"
rx = get_val "sodipodi:rx"
ry = get_val "sodipodi:ry"
assert(rx == ry)
Though to make the main code of the game the more simple related to the level data
I have made a first script that converts the Inkscape-SVG into binary datas.
You can have a look at this converter, it is very simple, only about 100 lines of code,
and quite trivial code, writen in about 30 minutes. This file is called 'mk-level-data.ml'
you can have a look at it in the tarball of the "simple-humble-toy-game" called rolling-moon:
http://www.linux-nantes.org/~fmonnier/O ... g-moon.php
To indicate which elements are of which kind, I've used the XML-editor of inkscape
to add "class" xml attributes, which is valid in svg, and which semanticaly is
close to the use done. The SVG reader then just reads this attribute to know
what to do with the different items.
The only tricky thing would be with non-polygon shapes defined with bezier curves.
I haven't handled this case yet, but it is not hard to convert the cubic beziers into segments.
I have copy-pasted bezier curves code from wikipedia yet in another project, so it
won't be hard at all.
I've seen that xmoto also uses Inkscape as its level design tool.
For C user, maybe there could be some code to steal from there?
I'm sure there should be other freedom software using inkscape too.
And about xmoto, do you know if there is someone who have tryed yet to make
an xmoto clone with Chipmunk?