log #11: Signs, fonts and windows

Time interval: 2024-03-04/2024-04-22

Don’t let the long time interval for this post fool you - I didn’t get much work done on the game as I was busy with other things, mainly laziness.

Signs

The first improvement is a long awaited feature that I never really got around to implementing. At least until now. I present to you: SIGNS.

While implementing signs, I managed to try out how entities with dynamic looks can be implemented. Until now, every entity just has a texture which is used to draw it. However, the sign text can be different for every sign and it would obviously not be a good idea to store a different a image file for every possible sign that is used in the game.

Since I still don’t have proper dynamic drawing support for entities (i. e. calling a custom draw function for each entity instead of the generic one), all this is done at load time in the loader function using tophat’s render target functionality.

First I render the text into an image. This also involves scaling the image in the y dimension by cos(30) to keep the perspective correct (30 degrees is the angle of the camera). Then I measure that image, so I know how big the sign has to be. If the text overlaps the default sign texture, I use nine-patch images to extend the sign. Then I just draw the text over it. The final sign with text is then just a normal texture that can be used as any other.

One might say that it is a bit inefficient to require two render targets to prepare a sign texture. I’m not sure about the performance implications, but I will definitely try exploring other ways of drawing dynamic entities.

Fonts

I finally decided to switch from the long used unifont for something a bit better. I decided to go with Oswald for the regular text and Courier Prime for monospaced text.

Windows

This is more of a technical change, but I moved the windowing logic from world.um to wm.um. This is beneficial for two reasons:

  1. The world.um file got a lot smaller
  2. I can now use the windows for other parts of the game (like the game menus)

If you are interesting in finding out more about the development of my game, or want to try playing a demo, you can visit our discord server.