Monday, September 26, 2011

Making a thrust like game for the iPad

I thought I'd post some information on one of the games I made for the iPad. I always loved the original Thrust game http://en.wikipedia.org/wiki/Thrust_(video_game)
So I inspired myself from the gameplay and from there tried to create a game on the iPad.

I developed a really cool level editor in Inkscape which is a free and open source vector drawing software. Here's a quick overview:

Here is the main editor. The main features are:
- naturally draw the level boundaries using the line tool (splines and lines)
- apply textures to "dress" the level (inspired from how I think they made rolando). The final exporter will clip those textures to the ground polygons. It helps greatly to break the repetitive pattern in dressing the level (we can show different parts of a texture depending on where it's placed)
- place physical objects around. For now there's: the lander, the landing pads, the turrets and the ball you have to carry around.
- draw the level bounding box so the camera never shows what's outside.


Once the .svg level is ready. I run a custom exporter written in C# to parse all the data (and convert the splines into lines with arbitrary precision). And then outputs an easy to parse level.xml file for the game

Every physical object is also designed inside inkscape. Here's for example lander.svg

The right drawing is the vectorial drawing of the lander.
On the left is a render of the drawing at the game's resolution. Around it is the physical shape of the object which can also contain additional properties to be used ingame. Here angulardamping is set to 0.9 and mass set to 1.
So again my C# exporter will export all this information into a convenient to parse lander.xml. When editing the level, it is sufficient to drop the rendered .bmp where we want the object to appear and the exporter will replace it with a reference to lander.xml in level.xml.

The game engine will take all these .xml files and run the level.

And here's the result on the iPad:


14 comments:

  1. this looks very interesting. do you plan to release the sources for the exporter code?

    ReplyDelete
  2. i am trying for 2 days now to load an svg in xcode and parse it but with no success. Can you please strip your essential code from your project and post a zip file with just that plain function ?
    Load an svg and show it in the simulator ?

    ReplyDelete
  3. What the hell, I'm not working on games these days. Here's the full source code.
    There's a C# project to convert the .svg into something easier to parse in Objective C
    C# code:
    https://rapidshare.com/files/2630582541/LevelExporter.rar
    Objective C:
    https://rapidshare.com/files/3702444466/ObjectiveC_Code.rar

    The C# should compile out of the box.
    I haven't included the art (too big), so I'm not sure how the Objective C will compile.

    Let me know how it goes and if I forgot something.
    It was a bit tricky to parse the .svg path I remember

    Enjoy !

    ReplyDelete
  4. Did i mention that you are awesome!?
    Thanks, i'll look into it. Perfect way to spend a Saturday :)

    ReplyDelete
  5. Its looking for this script...is this essential ?

    /scripts/PackTextures.sh: No such file or directory

    ReplyDelete
    Replies
    1. I am pretty sure i am doing the svg correctly in inkscape, yet

      XmlNodeList list = groundLayer.SelectNodes("ns:path", nsmgr);

      keeps giving me error msg, as if it cant find it.
      A small version of your svg map would be greatly appreciated to see it in a text editor on how its structured.
      I swear, i wont bother you again :P

      Delete
  6. No bother at all, I'm happy someone gets to use it.
    Here are the couple of levels I created
    https://rapidshare.com/files/1492119861/Levels.rar
    And the levels after being exported to xml
    https://rapidshare.com/files/2081507992/LevelsExported.rar

    You probably need to stick with that kind of layout for the levels. The exporter is not that flexible

    Let me know how it goes

    ReplyDelete
  7. Thanks for the files :), my inkscape makes the paths a liiiiitle bit different than yours...just have to figure out why now :)

    The LevelExporter continues now but says i am missing a gpc.dll. I went and found one on the net, but its not the proper one i guess. I got VS2008, is it something that should be there to use or am i missing something ?
    Thanks again.

    ReplyDelete
  8. Ah, its ok...if i hit continue it works.
    Whats in the update_doc_folder.bat ? something it needs in order to make the xmls, or should i try and 'pass' that function.

    ReplyDelete
  9. yeah pass it, this .bat file just copied the .xml files onto my mac computer.

    ReplyDelete
  10. Oh, GPC, yeah it's a polygon cutting library
    http://www.cs.man.ac.uk/~toby/gpc/
    I used it to place detail textures on the terrain and nicely clip all the polygons for rendering

    ReplyDelete
  11. finally, i manage to find a VMware 32bit XP system in one of my HDs and was able to get it working. Its missing png files now but i'll make my own and test this baby out :)
    Thanks

    ReplyDelete
  12. Oh and PackTextures.sh, was a script for
    http://www.codeandweb.com/texturepacker
    Something to pack the textures into 'atlases'.

    It's funny you're using vmware xp. I used vmware mac :)

    ReplyDelete
  13. Hey mate can u please reply me on chekuripratap@gmail.com would love to discuss on this project

    ReplyDelete