Making a Tilemap Editor in Lazarus
Posted at  2015-01-18 20:19:00+01:00
Author   Kostas "Bad Sector" Michalopoulos
Tags   lazarus tooldev

For a while now i wanted to show how Lazarus can be used to make game development tools - i use it for most of my own tools too! Lazarus is a GUI-oriented RAD IDE made in and for Free Pascal. It can be thought as a cross platform, open source Delphi, but it isn't exactly that (the APIs are similar but not compatible and while their feature sets overlap they have things which are only available to each).

I postponed it for a while (for about three years, since Lazarus 1.0 was released, to be exact :-P). But today i saw a message in /r/gamedev about needing a tile editor and one of the responses was to make your own. As it usually happens, another message was about not making your own :-P so i thought it was time to show how with the proper tools (Lazarus in this case) you wont have to spent much time making a little editor (and TBH even without Lazarus you shouldn't need more than 2-3 hours to make a tilemap editor with most UI libraries - but as i said, i wanted to show Lazarus!).

While it would be nice to have a full blown written or spoken tutorial, i am not good at that so i just decided to simply record myself (well, my screen) making the tile map editor and upload it to YouTube. I also sped it up a little (about 150%) because normally it would be slightly more than two hours (it still is more than one hour and a half), which can be boring.

The end program looks like this:

Editor

You can watch the whole video at YouTube:

To be honest, i was a little bored towards the end of the video which is why a few things were left unimplemented (resizing the map, displaying the mouse coordinates at the status bar and specifying the tile size for the map). All of them should be dead easy to implement though and you can consider them as excersizes for the reader (or audience in this case :-P). Also there is a small bug that by clicking to place a tile wont work unless you move the mouse - this is because tile placement is done in the OnMouseMove handler, so you probably can fix it easily if you call OnMouseMove from OnMouseDown.

The final code can be found at: http://www.mediafire.com/download/77ckiow6bynq8bx/TilemapEditor.zip

I'm also using my own little sprite editor which you can find at: http://runtimelegend.com/tools/mseditor/


   © 2009‑2016 Kostas Michalopoulos