Monsters are hedgehogs 🦔

This commit is contained in:
Yohann D'ANELLO
2020-11-10 21:47:36 +01:00
parent 3f374d2558
commit 3f4c809db6
8 changed files with 24 additions and 15 deletions

View File

@ -17,7 +17,7 @@ class MapDisplay(Display):
def update_pad(self) -> None:
self.pad.addstr(0, 0, self.map.draw_string(self.pack))
for e in self.map.entities:
self.pad.addstr(e.y, e.x, self.pack.PLAYER)
self.pad.addstr(e.y, e.x, self.pack[e.name.upper()])
def display(self) -> None:
y, x = self.map.currenty, self.map.currentx

View File

@ -15,6 +15,9 @@ class TexturePack:
self.__dict__.update(**kwargs)
TexturePack._packs[name] = self
def __getitem__(self, item):
return self.__dict__[item]
@classmethod
def get_pack(cls, name: str) -> "TexturePack":
return cls._packs[name.lower()]
@ -26,6 +29,7 @@ TexturePack.ASCII_PACK = TexturePack(
WALL='#',
FLOOR='.',
PLAYER='@',
HEDGEHOG='*',
)
TexturePack.SQUIRREL_PACK = TexturePack(
@ -34,4 +38,5 @@ TexturePack.SQUIRREL_PACK = TexturePack(
WALL='',
FLOOR='.',
PLAYER='🐿️',
HEDGEHOG='🦔',
)