Skip to content

Latest commit

 

History

History
59 lines (37 loc) · 1.94 KB

File metadata and controls

59 lines (37 loc) · 1.94 KB

Tileset

tcod-base supports the use of a single tileset, which can be created either from a .ttf or .otf font file or a .png tilesheet.

See python-tcod's documentation for details: tcod.tileset

Change the font/tilesheet

Add a font/tilesheet

If necessary, add a new font or tilesheet to the relevant assets directory.

Fonts are stored in /assets/fonts. Tilesheets are stored in /assets/tilesheets.

Modify font/tilesheet values

In constants.py:

  1. Set the TILE_SOURCE to either font or tilesheet.
TILE_SOURCE = "font"
or
TILE_SOURCE = "tilesheet"
  1. Modify the default font or tilesheet values.

The default font values, which may need modifying, are:

FONT = "DejaVuSansMono.ttf"
FONT_WIDTH = 20
FONT_HEIGHT = 20

See python-tcod's documentation for details: tcod.tileset.load_tilesheet

The default tilesheet values, which may need modifying, are:

TILESHEET = "terminal16x16_gs_ro.png"
TILESHEET_CHAR_MAP = tcod.tileset.CHARMAP_CP437
TILESHEET_COLUMNS = 16
TILESHEET_ROWS = 16

See python-tcod's documentation for details: tcod.tileset.load_truetype_font

How it works

The tileset is initialised during the InitState.

  • GameManager.__init__() (game_manager.py) sets the state to InitState

  • InitState.__init__() (init_state.py) calls tile_manager.__init__()

  • tile_manager.__init__() (tile_manager.py) calls tile_manager.load_tileset()

  • tile_manager.load_tileset() loads the tileset using either a font or tilesheet (as defined by the TILE_SOURCE value)