by Joe Flood on 22 November 2014
It's been 2 months and there's no word on the blog; what's going on?!
You'll recall last time I mentioned that I was adding in sound support to our game engine, Equinox right?
Well, we did it! And it all now works amazingly which is fantastic, but there was a much more important subsystem that needed writing - text support!
As a showcase for this, I decided to make a simple word game using Equinox - and of course to do that, I needed to support fonts and text. So, without further ado, behold! Text!
Doesn't look too great though as you can see, each letter is rendered at the same width, and they overlap in places. The waveyness (not a word, but I'm using it!) is intentional though, this demonstrated a pretty nifty Mexican wave effect when running!
So fast forward a week or so, and I've cleaned it all up and got it all working perfectly. AND I've put together a quick prototype game to show it off, as shown below:
So how does this work, you ask? Well, very simply actually! Thanks to a very nice piece of freeware, I'm able to give it any TrueType/OpenType font, and get it to create a bitmap of it, like this:
It also creates with it a file which describes where each character lives inside the font. Pretty neat, actually! You'll also notice it's white that's because the colour is added artificially using a shader program, so we can use any colour at runtime.
Okay, okay, but why didn't we just use something like opentype to render the fonts on-the-fly? Well, pretty much the only reason not to is just that it's simpler not to require another additional dependency, as this means more effort to port to other platforms. This is especially true since we're targeting everything from Windows to Mac to Linux to iOS and Android!
Phew - that was a huuuge blog post! So what's next? Next we'll be taking a very old 3D dungeon prototype and adding 2D GUIs into it!
Why? Because the game engine doesn't support GUIs yet and we're going to need them!