Linux Format logo

SDL and C#

Last night I had an epiphany of sorts. I've just finished reviewing a new Linux game for the magazine, and as I got up to go home it occurred to me, "this game was hardly advanced; how come there's nothing like it in the open source world?"

I wrote an SDL tutorial for LXF many issues ago, the infamous "Trout Wars" series. But if you followed that tutorial all the way through you might remember that the levels and enemies were loaded at run-time from text files, which meant that you could change various parts of the game just by editing the text files.

Anyway, the "epiphany" was this: what's stopping me taking the Trout Wars idea of runtime-loaded game components and extending it so that everything gets loaded dynamically - the animations, the keypresses, the actions, the movement of players and enemies, etc?

I walked home with Mike last night, and we discussed this all the way. My plan was to use XML for all the data files, then create a parser and SDL game engine that can handle any type of 2D game. By editing nothing more complex than XML, game designers could create racing games, platformers, or whatever. No coding knowledge required. Of course, ideally people wouldn't edit the XML by hand unless they wanted to - there would be some sort of XML-generating GUI that does most of the work. But that could all come later: get the game engine done first by hand-editing XML, then create a GUI later.

As I left Mike to walk on to my place, he said, "Is it possible?" I said, "I'll let you know tomorrow." So I started coding at 18:30, and, by 00:30, had the first vestiges of a working game engine. Basic, yes, but it read everything from XML, had transparent sprites, collision detection, mouse support and sound effects. I chose to use SDL and C# for development, and I've been thoroughly impressed with the ease of use of both systems - I seriously doubt I could have done anything like as much in six hours using C++. That said, although C# continues to amaze me, it does have some minor irritations - the need to call new() for unnamed objects, the inability to force a reference assign, etc.

Anyway, this morning I talked Mike through the code, and we got it compiling on his Ubuntu box. We even managed to add alpha blending, keyboard support, custom XML naming and animation in the hour or so we worked on it! It's early days yet, but we hope to have a half-decent release available to the general public by the end of this month, at which point we'll probably pick a project name and get it up on Sourceforge. Until then, it's top secret. Sorry!


Your comments



Web hosting by UKFast