12.05.05

Font Engine

Posted in ALPHA, Programming, SGE Enhancement at 1:47 am by Nick

Time: 2 hours
Total Time: 80 hours
——————————

Twas poking around Game Dev.net yesterday when I found an example of how to use fonts in your game. I modified the example to work with SGE (aka ripped out the DirectDraw stuff) and gave it a go. It seemed to work alright, though it flickered.

A few minutes later I realized I was drawing to the screen instead of the buffer (defeating the purpose of double buffer imaging). I fixed it for that and everything was quite snazzy.

After playing with it a bit I decided to expand it a bit more, and allow the user to specify weight*, strike through, underlined, and italic’s. This made the text a bit more useful.

I also figured I should make a few global fonts (mainly being Arial, Comic Sans MS, and Times New Roman in sizes 16 and 20) so I didn’t have to “create” them every time I wanted to use them. While it wasn’t really visible since the calculations for such a thing take nanoseconds, making an init_fonts() function just seemed like a good idea. I also made a default font that is used primarily, and you can change what it happens to be within the init_fonts() function.

All of this is leading to a messaging system, which is why I call this a font engine. Eventually it will support background images for text boxes so it will be a bit more like normal 2D games. While I’m not sure how I want this to be scripted, I do know I will eventually write the code to put this into the scripting system.

Overall the scripting system is a difficult subject, as it is only good at one thing currently. It is used for level creation. This is very nice, but it has nothing to do with events that happen during run time. I think I may want another scripter that can handle a level’s events. What this means is making a new system to parse new types of scripts. The scripts would specify what to do during certain events. A few examples are below:

- Print the opening dialogue using the font engine
- Play a cinema after an event (hmm, cinema support… ::adds to todo list::)
- What to do when the player dies
- Specify various behavior patterns of enemies (beyond the scope of the current AI scripting)
- Make, create, use, handle, and keep track of variables used for a certain stage (suppose a player is collecting items for a certain stage, etc)


*For those who don’t know, font weight is how thick it is. For example, normal weight (like the stuff you are reading) is weight 400. Normal bold is 800. Weight goes from 0-1000.

Leave a Comment