I decided to go ahead and write an editor. Writing a fairly feature-complete editor will hopefully allow me to get more and better content into the game in what little time I have.
I scheduled three hours for the editor, and worked for two. At that point I decided I needed some text, so I looked up SDL’s text handling functions. I was sure they wouldn’t take long to figure out.
Except that the SDL has no text handling functions. Oops.
Okay, the website has a list of SDL addons…surely someone has written a compatible text handling library.
Except that you can’t search the SDL website just for text handling libraries…you have to use their categories. I managed to find some, but I didn’t see any that met my needs: ie, complete, easy to integrate, fast to learn, and dirt-simple to use.
Okay, no problem. I’ll just grab the drawing context of my SDL application’s main window and use the GDI function DrawText() to put text on the screen. I’ll even get automatic word-wrapping!
Except that when I do this, the text flickers, no matter where I put it in the window update. This is almost certainly due to something the SDL main loop is doing that I have no control over.
Okay. I know the SDL works with OpenGL, and there’s a function called wglUseFontBitmaps() that allows the use of TrueType fonts in an OpenGL app. It seems kind of silly to require OpenGL support for the program just to write text to the screen, but everybody has OpenGL…
Except that when I enable OpenGL support, OpenGL basically takes over all display functions and calling something as simple as SDL_BlitSurface() causes the program to crash. I’d have to rewrite all of my drawing functions to use OpenGL instead of SDL. No thanks.
So I guess I’ll have to write my own real simple bitmap font handler. Fortunately, nine-tenths of the work has been done for me by Sol on this page (and Sol’s tutorials have been very helpful throughout this entire project, I’m going to have to send him a thank-you note).
I don’t like the included font, and Google has failed to help me find a font I like better that is in the proper format. I can legally exclude the time I’m spending getting the font system working from my project because it’s framework stuff, but the font will actually be visible on the screen, so if I make my own font, that time will count against my forty hours. Can I afford to spend a half-hour putting together an alternate font? If I do, I can use a font from an old Commodore 64 RPG like Legacy of the Ancients, which will contribute even more to the game’s old-school feel. But is that the best use of my time?
If I say “I’ll make one at the end of the project if I’ve got some spare time” then it won’t get made, because I won’t have any spare time. And I want it. So I’m going to do it. I’ll probably regret doing this around the 35 hour mark, just as I’ll regret spending three hours putting tiles together, but I want what does get on the screen to look as nice as it can.
One of the reasons why SDL does not have text handling routines is that it is difficult to draw a line on what’s “good enough”.
The text drawing functions I describe in my tutorial cover what I consider the bare minimum, but even they might be more than “good enough” for some – for instance, if you only have fixed-width font.
But what happens after you have simple proportional font, and you want to improve it? Word wrapping? Better kerning for letter pairs? Non-western fonts? Writing directions? Bidirectional font support? Letter-morphing? And so on.
After a while you have some kind of huge monster that represents a meaningful percentage of an operating sytem. =)
Thus, SDL makers have opted not to play at all. And it’s OK, since simple bitmap font printer, like the one in my tutorials, can be whipped out in a couple of hours (less, if you’re done it before =)
Oddly enough, I had to solve a lot of these problems (word wrapping and internationalization) on my current project at work, which uses bitmap fonts, but I couldn’t really use that code for my own game. Creating the bitmap font system didn’t take long at all, especially with your code to start from (thanks again). It just kind of rankled that I had to do it at all. Anyhoo, it’s done, I found a font I like and I can get back to actually writing the game.