50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
from typing import Tuple
|
|
|
|
import numpy as np # type: ignore
|
|
|
|
graphic_dt = np.dtype(
|
|
[
|
|
("ch", np.int32), # unicode codepoint
|
|
("fg", "3B"), # RGB
|
|
("bg", "3B"),
|
|
]
|
|
)
|
|
|
|
tile_dt = np.dtype(
|
|
[
|
|
("walkable", np.bool), # True if can be walked over
|
|
("transparent", np.bool), # True if doesn't block FOV
|
|
("dark", graphic_dt), # graphics for when this tile is not in FOV
|
|
("light", graphic_dt), # graphics for when this tile is not in FOV
|
|
]
|
|
)
|
|
|
|
|
|
def new_tile(
|
|
*, # keywords only
|
|
walkable: int,
|
|
transparent: int,
|
|
dark: Tuple[int, Tuple[int, int, int], Tuple[int, int, int]],
|
|
light: Tuple[int, Tuple[int, int, int], Tuple[int, int, int]],
|
|
) -> np.ndarray:
|
|
"""helper function for making tiles"""
|
|
return np.array((walkable, transparent, dark, light), dtype=tile_dt)
|
|
|
|
|
|
# SHROUD represents unexplored, unseen tiles
|
|
SHROUD = np.array((ord(" "), (255, 255, 255), (0, 0, 0)), dtype=graphic_dt)
|
|
|
|
floor = new_tile(
|
|
walkable=True,
|
|
transparent=True,
|
|
dark=(ord(" "), (255, 255, 255), (50, 50, 150)),
|
|
light=(ord(" "), (255, 255, 255), (200, 180, 50)),
|
|
)
|
|
|
|
wall = new_tile(
|
|
walkable=False,
|
|
transparent=False,
|
|
dark=(ord(" "), (255, 255, 255), (0, 0, 150)),
|
|
light=(ord(" "), (255, 255, 255), (130, 110, 50)),
|
|
)
|