Ludum Dare is coming up, so participants are posting what they are going to use to make their games. I was hoping I’d come across a program that is to tiles as sfxr is to sound effects. Tiles, like in Final Fantasy 6. Small, say, 16 by 16 pixel images whose edges agree and come together to form a bigger picture. I’m no artist in the tile drawing sense, and I suppose I was counting on finding such a program more than I realized until now.
I haven’t come across any such thing. In fact I’ve been working on the problem, but didn’t expect to not find anyone who did it better than me already. So I cleaned up what I had, slapped on an interface, and here’s the result. I’m probably going to be using it, so according to the rules anyone else has to be able to as well. I have a precompiled windows distribution and the source here. As long as you’re familiar with SDL, it shouldn’t be too hard to compile. If you aren’t familiar with SDL, I tell you it’s one of the easiest libraries to get familiar with, especially because of these tutorials. To be clear, you don’t have to understand SDL API to compile it, but you do have to be familiar with including libraries and any specific requirements they have. Covered in the tutorials.
A tip for any Microsoft Visual Studio 2010 Express users. At the top left of windows like this, you can see the configuration is set to “Active (Debug)” which means if you ever want to compile in release, you have to reconfigure everything again. Set it to “All Configurations”. Also, before you open your project’s properties, make sure you have the project selected, not the solution (in the Solution Explorer, which I believe is at the left by default). Otherwise you won’t find the options you’re looking for and wonder why.
tiles2d.hpp and tiles2d.cpp are the meat of tile making. Lift them out and include elsewhere if you can’t stand my interface or want to do something else.
sdlgraphics.hpp and sdlgraphics.cpp are some handy graphics functions (particularly vector text) I made for SDL a long time ago. If it looks gross it’s because I haven’t bothered cleaning it up yet, just small updates as I’ve needed. This isn’t really what the project is about, but it’s here and maybe it’s useful.
bmp.hpp and bmp.cpp are translations of a certain subset of bitmap file format to c++. I haven’t come across anything like them; I don’t know if I’m crazy for liking pieces of code that do one thing exactly and simply, or if I just don’t know where to find them. Again, not the focus of the project, but maybe useful for you.
main.cpp is messy. I was never intending to make a clean interface so much as a quick and dirty one, and this is the meat of the interface. I don’t feel like there’s much to say about it. It has a rudimentary “compiler”, views similar to, well, how I think iPhone programming should work, and some tricks I think are cool that you could probably find online if you ever came across the problem they solve.
I’m not too clear on how to enforce licenses, since you can just cut up my code and pretend it was never mine to begin with. In any case, my intention for the code is that you use it however you want, as long as you don’t bring about the following situation I have nightmares about, in which I improve upon the code, get rich, and then have you sue me by somehow “proving” the code is your intellectual property.
Here’s what the results can look like. 32×32 tiles; my take on snow, grass, water, dirt; 2 of the transition tiles between grass and water.