SVG Game Engine – Movement is Tricky

I sat down today with the project in order to get some rudiments of movement working, and quickly ran into an issue.  Namely, in the old version of the project in C++, I wasn’t directly drawing the ShivaVG paths.  Instead I was drawing to a pixel buffer which was then used as the texture for quads.  This enabled me to have an absolute position in the scene for any given object, and movement was a simple matter of translating the quad around.  That made sense in the old project because it was the easiest way to draw the objects in the first place. Not so in the new project.

So, what did I do you may ask?  Well, after much mucking about in the OpenVG spec and other searching around, I became a bit stumped and was almost ready to rewrite my code to do things the old way.  However, with a bit of rethinking, I realized that if I change all the path objects to use relative coordinates (a setting which I had disabled in Inkscape because I was getting lazy earlier when writing the parsing code, but which is no longer an issue after I refactored it), I can simply update the initial move to command in the path, and clear and reinitialize the path data, which will give me a simple path-specific translation.  Wonderful!

Amusingly enough, if you do this using paths that are forced to use only absolute commands, you get a nice ‘Scream‘-like effect:

Ninja Melt

The rects are drawn differently, so they don't melt.

I also figured out how to enable anti-aliasing in SFML, which makes things look a lot nicer.  Unfortunately, my development PC is a little low-end in the graphics department so it performs rather badly at 6xAA.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s