1. Alexander Malinin
  2. BearLibTerminal
  3. Issues
Issue #43 new

Font+Tiles+Colors Question

Steve Losh
created an issue

This isn't really a bug, more of just a question on how to do something.

Let's say I'm making a little roguelike. I'd like to start by just loading a font and using unicode characters for everything, so I do something like this:

(blt:set "tile font: ./assets/ProggySquare/ProggySquare.ttf, size=16x16, align=dead-center;")

Later I want to add support for tiles, but I don't want to have to make every single tile before I try them out. Ideally what I want is to load a png of tiles into certain character slots, and have the original font used as a fallback for characters that don't have a tile. So I do something like:

(blt:set "tile font: ./assets/ProggySquare/ProggySquare.ttf, size=16x16, align=dead-center;")
(when *enable-tiles*
  (blt:set "tile 0x0000: ./assets/tiles.png, size=16x16, resize=16x16, align=dead-center, codepage=./assets/codepage.txt;"))

This works great, except when I want to add color. When drawing a character that has a tile, I'd like to just use the pixels from the tile untinted. But when drawing a fallback character from the font, I want to use a specific color. E.g. I want to draw goblins as a brown g if they have no tile, but as the untinted tile if they do. But when I call terminal_color it tints the tile.

What's the proper way to go about doing this?

Comments (1)

  1. Alexander Malinin repo owner

    I'd solve this in the game logic with a simple wrapper function to put a tile, which would check some map/cache to decide which color to use. You'll end up with some tile information registry anyway, it may also contain a flag which will control the coloring (or absence of coloring).

    One of the basic ideas of the library is that it treats characters/tiles/sprites more or less equally. Because of that you can replace the character with a tile, and because of that the tile will be a subject to regular processing, i. e. colored during output.

    While it might be possible to somehow make certain tiles special so that terminal do not color them, I do not like this idea. Making minor but specialized exceptions here and there feels off and will probably require some complex configuration to pull off.

  2. Log in to comment