Fix texture packs
This commit is contained in:
parent
02d3394439
commit
b3d789e3e7
@ -7,6 +7,9 @@ class TexturePack:
|
||||
FLOOR: str
|
||||
PLAYER: str
|
||||
|
||||
ASCII_PACK: "TexturePack"
|
||||
SQUIRREL_PACK: "TexturePack"
|
||||
|
||||
def __init__(self, name: str, **kwargs):
|
||||
self.name = name
|
||||
self.__dict__.update(**kwargs)
|
||||
|
@ -46,7 +46,7 @@ class Map:
|
||||
lines = [line for line in lines if line]
|
||||
height = len(lines)
|
||||
width = len(lines[0])
|
||||
tiles = [[Tile(c)
|
||||
tiles = [[Tile.from_ascii_char(c)
|
||||
for x, c in enumerate(line)] for y, line in enumerate(lines)]
|
||||
|
||||
return Map(width, height, tiles)
|
||||
@ -65,6 +65,13 @@ class Tile(Enum):
|
||||
WALL = auto()
|
||||
FLOOR = auto()
|
||||
|
||||
@classmethod
|
||||
def from_ascii_char(cls, ch: str) -> "Tile":
|
||||
for tile in Tile:
|
||||
if tile.char(TexturePack.ASCII_PACK) == ch:
|
||||
return tile
|
||||
raise ValueError(ch)
|
||||
|
||||
def char(self, pack: TexturePack) -> str:
|
||||
return getattr(pack, self.name)
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
███████ █████████████
|
||||
█.....█ █...........█
|
||||
█.....█ █████...........█
|
||||
█.....█ █...............█
|
||||
█.█████ █.███...........█
|
||||
█.█ █.█ █...........█
|
||||
█.█ █.█ █████████████
|
||||
█.█ █.█
|
||||
█.████ █.█
|
||||
█....█ █.█
|
||||
████.███████████████████.█
|
||||
█.....................█ █████████████████
|
||||
█.....................█ █...............█
|
||||
█.....................███████...............█
|
||||
█...........................................█
|
||||
█.....................███████...............█
|
||||
███████████████████████ █████████████████
|
||||
####### #############
|
||||
#.....# #...........#
|
||||
#.....# #####...........#
|
||||
#.....# #...............#
|
||||
#.##### #.###...........#
|
||||
#.# #.# #...........#
|
||||
#.# #.# #############
|
||||
#.# #.#
|
||||
#.#### #.#
|
||||
#....# #.#
|
||||
####.###################.#
|
||||
#.....................# #################
|
||||
#.....................# #...............#
|
||||
#.....................#######...............#
|
||||
#...........................................#
|
||||
#.....................#######...............#
|
||||
####################### #################
|
||||
|
Loading…
Reference in New Issue
Block a user