Tales of a level editor

November 14th, 2009

While having lua scripts as level files is very flexible and “hackable”, it’s really difficult to “see” the level just by looking at a series of instructions.

At first, I used Inkscape, the open source vector drawing program, to create my levels.
It seemed like a perfectly good idea: Just like my game engine, Inkscape uses shapes to define the drawing. Also, since SVG files are basically XML files, any XML loader can be used to read the content of the drawing and extrapolate a game level script.

The real benefit was, however, that I didn’t need to write a level editor, but just a simple program that converts .svg files in lua scripts. I estimated that writing a converter instead of a level editor would save me a lot of time.

I estimated wrong :)

The problems I had with this approach were many, but here are the best ones:

  1. I found it really difficult to come up with a series of consistent rules for setting shape properties. I started putting different object types in different layers, so the unmovable shapes would be in a layer named “unmovable”, the movable ones would be in the “movable” layer, the powerups in another one, the traps in yet another layer.
  2. It’s almost impossible to align everything correctly in Inkscape
  3. Inkscape doesn’t save the shape rotation in the SVG file, but only the transformation matrix.

In the end, frustrated by my poor choice, I decided to finally write a level editor.
It took me just a couple of evenings to create a decent c# application that does exactly what I want:

Level editor screenshot

One of the best features is the ability to import the bitmap files I create as mockups and transform them in levels:

level data mockup

(click the picture for a 5x enlarged version)

I have to say that c#/.net 3.5 is a wonderful combination for creating applications quickly!

Lesson learned: Sometimes it is better to create (and eat) your own dogfood :)

Font rendering and the joys of C++

October 21st, 2009

At the moment, all the menu text in the game is stored in separated images – one for every menu item. For example, this is the “New Game” button:

menu-newgame

Of course, storing each menu item as a separate picture is not very efficient, so I decided to add text rendering capability to the game.

My first choice was the OGLFT library. It’s a really easy to use and complete OpenGL text rendering library based on FreeType. I quickly added it to the project, and it worked perfectly, until I closed the application and got a nice “Access violation” exception :(

After hours of tinkering, I finally found out that the error was related to the FreeType library. For some mysterious reason, just trying to open a font file with FreeType caused the erroneous behavior.

So, since I couldn’t use FreeType, I decided to create a text rendering class myself, based on the font texture approach.

In order to create suitable font maps, I modified Irrlicht Font Maker to create non-irrlicht-specific font maps. I also added a couple of options and the ability to export the control points as custom text  or in a handy binary format:

New Options in Irrlicht Font Maker Text export

But that’s only the first part of the story: once ready, I took my new text rendering class for a test drive and, with much surprise, I discovered that the program triggered the same exception it did before! OH MY!

After an hour or so of debugging, I finally found out the root cause of the problem: a single call to fopen to read the font control points was enough to send the program to C++ hell.

I have since replaced all the standard C file IO functions (fopen, fread, …) with the modern C++ equivalent (fstream) and now the program ends with no errors.

In the end, I’m happy with the new font rendering method, as it gave me a chance to clean up and improve Irrlicht Font Maker, however once again I feel like I misplaced my foot in the minefield that is programming in C++ :)

Getting rid of the Naming container in ASP.Net 2.0 – update

October 6th, 2009

In my previous article, Getting rid of the Naming Container in asp.net 2.0, I explained a method to override the extended naming functionality provided by ASP.net in order to create client-side controls with better IDs.

I was however informed in the comments that by overriding the NamingContainer property the control loses the ability to read its value from the PostBack data.

Since the controls I developed were not meant to to be used in a postback scenario, this wasn’t a big problem for me.

Fast-forward a couple of years and here I am, wondering why post back does not work in one of my projects ;)

Anyway, I looked at the link provided by Alex, where Rick Strahl talks about overriding the ClientId and the UniqueId properties instead of NamingContainer.

In a standard web control, the two properties ClientID and UniqueID are mapped, respectively, to the id and name properties of the HTML control generated.

Since most (all? ) JS frameworks use the id property to access the varius HTML elements and the PostBack mechanism uses the name property, I think the “best of both worlds” solution is to only override the ClientId:

<p><span class="kwrd">public</span> <span class="kwrd">class</span> NiceTextBox : System.Web.UI.WebControls.TextBox
{
    <span class="kwrd">public</span> <span class="kwrd">bool</span> UseNamingContainer { get; set; }
</p><p>    <br />    <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">string</span> ClientID
    {
        get
        {
            <span class="kwrd">if</span> (<span class="kwrd">this</span>.UseNamingContainer)
                <span class="kwrd">return</span> <span class="kwrd">base</span>.ClientID;
            <span class="kwrd">else</span>
                <span class="kwrd">return</span> <span class="kwrd">this</span>.ID;
        }
    }
}
</p>

Now our NiceTextBox works even during post-back scenarios :)

The game: baby steps

August 27th, 2009

pastedpic_01212009_132627

Here is an early screenshot from the game I’m working on. Obviously all the programmer art you see is temporary and will be replaced by something better :)

Still alive + Working on a game…

July 28th, 2009

…and I’m going to document the whole process on this blog :)

It will be a 2D mario-style platformer, whith a twist: the game is set on a physically realistic world. More details to come soon!

I also have a very cool productivity (“serious”) application to release. Testing is complete, I just need to get the boring part done (creating setups, writing web pages…).

Clock 3D Screensaver released

February 7th, 2009

It’s finally out! Go get it!

gljakal’s ToDo 0.9.3 fix

January 22nd, 2008

I have updated gljakal’s ToDo to fix a nasty bug that occurred when you tried to create a new to-do list with the AdvancedStatus plugin disabled and the AutoBackup plugin enabled.
This was actually a kind of weird situation, since I always have both the plugins enabled all the time… Turns out that many ToDo users prefer to disable AdvancedStatus while leaving the backup feature enabled….
Anyway, thanks to the kind people who sent the error report! (yes, I do actually read them!)
Also, if any of you happen to send an error report, please do include your email address. This way I can contact you once the problem is resolved. (And you won’t say “this program sucks!” :) )

New software – gljakal’s Sql Exporter

December 19th, 2007

You created a database for your application. You designed the perfect table structure, added some smart views and created the coolest stored procedures that make your application work like magic.

But now, you want to back them up together with the code of your program, using subversion or CVS. Afterall, they are part of the application logic.

Better yet, you would like to automate the extraction procedure so that you only need to launch a batch file and your backup is done.

Gljakal’s Sql Exporter does just that: it extracts tables, views, stored procedures and triggers from your database and saves them as individual text files.

Used together with a source control software, you can have a precise idea of what changed between the various releases, just like you do with your applications’ source code.

gljakal's Sql Exporter

You can do that with the interface version (shown in the picture) as well as with the command line version, that you can automate to run whenever you want.

Plus, it’s a free download!

gljakal’s ToDo version 0.9.3

October 26th, 2007

Finally!
Today I am releasing the new, improved version of gljakal’s ToDo:


ToDo version 0.9.3

New version highlights:

  • Stable, documented plugin support:
    Now adapting ToDo to your needs is easier than ever. Plugin support is great for custom exports and imports, intranet integration, even synchronization with online services!
  • New, nicer user interface, with famfamfam’s famous icons.
  • AdvancedStatus plugin
    Now you can set a task as 50% (or any %) complete!
  • Copy & paste inside the details window
    You could already do this with CTRL-C and CTRL-V, but now there are also cut-copy-paste buttons inside the details window
  • Help file
    Now you can press F1 inside todo and actually see something :)
  • All the new features in the preview release

Comments & critics are welcome!

Free Burma Day

October 4th, 2007

Free Burma!
More information at http://www.free-burma.org.