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