/
tile_types.py
59 lines (53 loc) · 1.75 KB
/
tile_types.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Eric Janusson
# Python 3.9
'''⌬
Description: Assign tile data types
⌬'''
from typing import Tuple
import numpy as np
# tile 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 used for static tile data
tile_dt = np.dtype(
[
('walkable', np.bool_), # true if this tile can be walked over
('transparent', np.bool_), # true if this tile doesn't block view
('dark', graphic_dt), # graphics for when this tile is not in view
('light', graphic_dt), # graphics for when the tile is in view
]
)
def new_tile(
*, # parameter order doesn't matter.
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 defining tile types '''
return np.array((walkable, transparent, dark, light), dtype=tile_dt)
# SHROUD is 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, 20, 100)),
light=(ord(' '), (255, 255, 255), (150, 90, 40)),
# 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, 100)),
light=(ord(' '), (255, 255, 255), (60, 55, 20)),
# dark=(ord(' '), (255, 255, 255), (0, 0, 100)),
# light=(ord(' '), (255, 255, 255), (130, 110, 50)),
)