1
0
python-roguelike/game_map.py

18 lines
586 B
Python
Raw Normal View History

2022-01-06 13:27:15 -05:00
import numpy as np # type: ignore
2022-01-06 11:41:34 -05:00
from tcod.console import Console
import tile_types
2022-01-06 13:27:15 -05:00
2022-01-06 11:41:34 -05:00
class GameMap:
def __init__(self, width: int, height: int):
2022-01-06 13:27:15 -05:00
self.width, self.height = width, height
self.tiles = np.full((width, height), fill_value=tile_types.wall, order="F")
2022-01-06 11:41:34 -05:00
def in_bounds(self, x: int, y: int) -> bool:
2022-01-06 13:27:15 -05:00
"""Return True if x and y are inside the bounds of the map."""
2022-01-06 11:41:34 -05:00
return 0 <= x < self.width and 0 <= y < self.height
def render(self, console: Console):
2022-01-06 13:27:15 -05:00
console.tiles_rgb[0: self.width, 0: self.height] = self.tiles["dark"]