Texture packs are working

This commit is contained in:
Yohann D'ANELLO
2020-11-06 17:43:30 +01:00
parent 4115363b74
commit f9dcc8f1c1
6 changed files with 61 additions and 38 deletions

View File

@ -1,7 +1,8 @@
#!/usr/bin/env python
from enum import Enum
from dungeonbattle.settings import Settings
from dungeonbattle.display.texturepack import texturepack
from enum import Enum, auto
from dungeonbattle.display.texturepack import TexturePack
class Map:
"""
@ -44,24 +45,22 @@ class Map:
return Map(width, height, tiles, [])
def draw_string(self) -> str:
def draw_string(self, pack: TexturePack) -> str:
"""
Draw the current map as a string object that can be rendered
in the window.
"""
return "\n".join("".join(tile.value for tile in line)
return "\n".join("".join(tile.char(pack) for tile in line)
for line in self.tiles)
class Tile(Enum):
if self.settings.TEXTURE_PACK == 'ASCII' :
self.textures = tp.ascii_textures
if self.settings.TEXTURE_PACK == 'SQUIRREL' :
self.textures = tp.squirrel_textures
EMPTY = self.textures["EMPTY"]
WALL = self.textures["WALL"]
FLOOR = self.textures["FLOOR"]
EMPTY = auto()
WALL = auto()
FLOOR = auto()
def char(self, pack: TexturePack) -> str:
return getattr(pack, self.name)
def is_wall(self) -> bool:
return self == Tile.WALL