-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_map.py
24 lines (18 loc) · 963 Bytes
/
game_map.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
import numpy as np
from tcod.console import Console
import tile_types
class GameMap:
def __init__(self, width: int, height: int):
self.width, self.height = width, height
self.tiles = np.full((width, height), fill_value=tile_types.wall, order="F")
self.visible = np.full((width, height), fill_value=False, order="F") #Tiles the player can currently see
self.explored = np.full((width, height), fill_value=False, order="F") #Tiles the player has seen before
def in_bounds(self, x: int, y: int) -> bool:
"""Return True if x and y are inside the bounds of this map."""
return 0 <= x < self.width and 0 <= y < self.height
def render(self, console: Console) -> None:
console.tiles_rgb[0: self.width, 0: self.height] = np.select(
condlist=[self.visible, self.explored],
choicelist=[self.tiles["light"], self.tiles["dark"]],
default=tile_types.SHROUD
)