-
Notifications
You must be signed in to change notification settings - Fork 0
/
tile_types.py
139 lines (128 loc) · 3.95 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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", bool), # True if this tile can be walked over.
("transparent", bool), # True if this tile doesn't block FOV.
("dark", graphic_dt), # Graphics for when this tile is not in FOV.
("light", graphic_dt), # Graphics for when the tile is in FOV.
]
)
def new_tile(
*, # Enforce the use of keywords, so that 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 individual tile types"""
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)
unknown = new_tile(
walkable=False,
transparent=False,
dark=(ord("?"), (255, 255, 255), (22, 24, 43)),
light=(ord("?"), (255, 255, 255), (50, 50, 100)),
)
floor = new_tile(
walkable=True,
transparent=True,
dark=(ord(" "), (255, 255, 255), (22, 24, 43)),
light=(ord(" "), (255, 255, 255), (50, 50, 100)),
)
wall = new_tile(
walkable=False,
transparent=False,
dark=(ord(" "), (255, 255, 255), (31, 32, 45)),
light=(ord(" "), (255, 255, 255), (70, 70, 100)),
)
arch = new_tile(
walkable=True,
transparent=True,
dark=(ord("π"), (31, 32, 45), (22, 24, 43)),
light=(ord("π"), (70, 70, 100), (50, 50, 100)),
)
pillar = new_tile(
walkable=False,
transparent=False,
dark=(ord("o"), (31, 32, 45), (22, 24, 43)),
light=(ord("o"), (70, 70, 100), (50, 50, 100)),
)
fence = new_tile(
walkable=False,
transparent=True,
dark=(ord("#"), (31, 32, 45), (22, 24, 43)),
light=(ord("#"), (70, 70, 100), (50, 50, 100)),
)
closed_door = new_tile(
walkable=False,
transparent=False,
dark=(ord("+"), (120, 120, 120), (31, 32, 45)),
light=(ord("+"), (255, 255, 255), (70, 70, 100)),
)
open_door = new_tile(
walkable=True,
transparent=True,
dark=(ord("-"), (120, 120, 120), (22, 24, 43)),
light=(ord("-"), (255, 255, 255), (50, 50, 100)),
)
down_stairs = new_tile(
walkable=True,
transparent=True,
dark=(ord(">"), (120, 120, 120), (22, 24, 43)),
light=(ord(">"), (255, 255, 255), (50, 50, 100)),
)
up_stairs = new_tile(
walkable=True,
transparent=True,
dark=(ord("<"), (120, 120, 120), (22, 24, 43)),
light=(ord("<"), (255, 255, 255), (50, 50, 100)),
)
dirt_floor = new_tile(
walkable=True,
transparent=True,
dark=(ord(" "), (255, 255, 255), (93, 82, 32)),
light=(ord(" "), (255, 255, 255), (200, 180, 50)),
)
cave_wall = new_tile(
walkable=False,
transparent=False,
dark=(ord(" "), (255, 255, 255), (58, 49, 26)),
light=(ord(" "), (255, 255, 255), (130, 110, 50)),
)
cave_down_stairs = new_tile(
walkable=True,
transparent=True,
dark=(ord(">"), (0, 0, 100), (93, 82, 32)),
light=(ord(">"), (255, 255, 255), (200, 180, 50)),
)
cave_up_stairs = new_tile(
walkable=True,
transparent=True,
dark=(ord("<"), (0, 0, 100), (93, 82, 32)),
light=(ord("<"), (255, 255, 255), (200, 180, 50)),
)
red = new_tile(
walkable=True,
transparent=True,
dark=(ord(" "), (255, 255, 255), (82, 24, 50)),
light=(ord(" "), (255, 255, 255), (100, 50, 50)),
)
blue = new_tile(
walkable=False,
transparent=True,
dark=(ord(" "), (255, 255, 255), (50, 50, 83)),
light=(ord("X"), (255, 255, 255), (50, 50, 100)),
)
stair_tiles = [down_stairs, up_stairs, cave_down_stairs, cave_up_stairs]
door_tiles = [closed_door, open_door]