2022-01-06 11:41:34 -05:00
|
|
|
from typing import Tuple
|
|
|
|
|
|
|
|
import numpy as np # type: ignore
|
|
|
|
|
|
|
|
# Tile graphics structured type compatible with Console.tiles_rgb.
|
|
|
|
graphic_dt = np.dtype(
|
|
|
|
[
|
|
|
|
("ch", np.int32), # Unicode codepoint.
|
|
|
|
("fg", "3B"), # 3 unsigned bytes, for RGB colors.
|
|
|
|
("bg", "3B",)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
# Tile struct used for statically defined tile data.
|
|
|
|
tile_dt = np.dtype(
|
|
|
|
[
|
|
|
|
("walkable", np.bool), # True if this tile can be walked over.
|
2022-01-06 13:27:15 -05:00
|
|
|
("transparent", np.bool), # True if this tile doesn't block FOV.
|
|
|
|
("dark", graphic_dt), # Graphics for when this tile is not in FOV.
|
2022-01-07 14:18:47 -05:00
|
|
|
("light", graphic_dt), # Graphics for when the tile is in FOV.
|
2022-01-06 11:41:34 -05:00
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2022-01-06 13:27:15 -05:00
|
|
|
|
2022-01-06 11:41:34 -05:00
|
|
|
def new_tile(
|
2022-01-06 13:27:15 -05:00
|
|
|
*, # Enforce the use of keywords, so that parameter order doesn't matter
|
|
|
|
walkable: int,
|
|
|
|
transparent: int,
|
2022-01-07 14:18:47 -05:00
|
|
|
dark: Tuple[int, Tuple[int, int, int], Tuple[int, int, int]],
|
|
|
|
light: Tuple[int, Tuple[int, int, int], Tuple[int, int, int]]
|
2022-01-06 11:41:34 -05:00
|
|
|
) -> np.ndarray:
|
|
|
|
"""Helper function for defining individual tile types"""
|
2022-01-07 14:18:47 -05:00
|
|
|
return np.array((walkable, transparent, dark, light), dtype=tile_dt)
|
2022-01-06 11:41:34 -05:00
|
|
|
|
|
|
|
|
2022-01-07 14:18:47 -05:00
|
|
|
# SHROUD represents unexplored, unseen tiles
|
|
|
|
SHROUD = np.array((ord(" "), (255, 255, 255), (0, 0, 0)), dtype=graphic_dt)
|
|
|
|
|
2022-01-06 11:41:34 -05:00
|
|
|
floor = new_tile(
|
|
|
|
walkable=True,
|
|
|
|
transparent=True,
|
2022-01-07 14:18:47 -05:00
|
|
|
dark=(ord(" "), (255, 255, 255), (50, 50, 150)),
|
|
|
|
light=(ord(" "), (255, 255, 255), (200, 180, 50)),
|
2022-01-06 11:41:34 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
wall = new_tile(
|
|
|
|
walkable=False,
|
|
|
|
transparent=False,
|
2022-01-07 14:18:47 -05:00
|
|
|
dark=(ord(" "), (255, 255, 255), (0, 0, 100)),
|
|
|
|
light=(ord(" "), (255, 255, 255), (130, 110, 50)),
|
2022-01-06 13:27:15 -05:00
|
|
|
)
|