State of the Game
Bunnies! C# finally has a title screen. One of the things I noticed immediately is that the font was very hard to read over the title image. So I added a new feature to the font class: borders. There are a couple ways to add borders to text. The first attempt was to go over the font bitmap four times: left to right, right to left, top to bottom and bottom to top. When it hit a non-masked pixel it would start plotting solid color pixels until X were placed or it hit a masked pixel. This worked fine for very thin borders of only a pixel or two but thicker borders started to show the limitations. Because the border was inside the font and using four directions caused sharp corners, thick borders got very ugly very fast.
The second attempt takes a more sophisticated approach. One pass is made across the entire image and when a non-masked pixel is found circles are made around the point up to X pixels in radius and any masked pixels found are changed to the border color. This makes the border outside the font and creates a nice rounded border around curved letters like “S”.
The thick black border makes the text much more readable. The border can actually be any color. I may also add a masking method which allows you to specify what color to apply a texture to. So for example a downward gradient can be applied to the font. A border can be made and then an upward gradient could be applied to the border.
One of the big pains of game programming is creating fonts. It’s nice to have as much flexibility as possible to allow for dynamic fonts so you don’t have to manually make a font map which is tedius and time consuming.
Leave a comment
You must be logged in to post a comment.