diff --git a/squirrelbattle/display/mapdisplay.py b/squirrelbattle/display/mapdisplay.py index 7e21adb..3a21470 100644 --- a/squirrelbattle/display/mapdisplay.py +++ b/squirrelbattle/display/mapdisplay.py @@ -19,8 +19,11 @@ class MapDisplay(Display): def update_pad(self) -> None: self.pad.resize(500, 500) - self.addstr(self.pad, 0, 0, self.map.draw_string(self.pack), - self.pack.tile_fg_color, self.pack.tile_bg_color) + for i in range(self.map.height): + for j in range(self.map.width): + self.addstr(self.pad, i, j * self.pack.tile_width, + self.map.tiles[i][j].char(self.pack), + *self.map.tiles[i][j].color(self.pack)) for e in self.map.entities: self.addstr(self.pad, e.y, self.pack.tile_width * e.x, self.pack[e.name.upper()], diff --git a/squirrelbattle/display/texturepack.py b/squirrelbattle/display/texturepack.py index 77bbfc7..44a8265 100644 --- a/squirrelbattle/display/texturepack.py +++ b/squirrelbattle/display/texturepack.py @@ -91,7 +91,7 @@ TexturePack.SQUIRREL_PACK = TexturePack( EMPTY=' ', EXPLOSION='💥', FLOOR='██', - LADDER='🪜', + LADDER=('🪜', curses.COLOR_WHITE, curses.COLOR_WHITE), HAZELNUT='🌰', HEART='💜', HEDGEHOG='🦔', diff --git a/squirrelbattle/interfaces.py b/squirrelbattle/interfaces.py index 788edaa..ff94cc6 100644 --- a/squirrelbattle/interfaces.py +++ b/squirrelbattle/interfaces.py @@ -4,7 +4,7 @@ from enum import Enum, auto from math import sqrt from random import choice, randint -from typing import List, Optional, Any +from typing import List, Optional, Any, Tuple from .display.texturepack import TexturePack from .translations import gettext as _ @@ -218,7 +218,19 @@ class Tile(Enum): Translates a Tile to the corresponding character according to the texture pack """ - return getattr(pack, self.name) + val = getattr(pack, self.name) + if isinstance(val, tuple): + return val[0] + return val + + def color(self, pack: TexturePack) -> Tuple[int, int]: + """ + Retrieve the tuple (fg_color, bg_color) of the current Tile. + """ + val = getattr(pack, self.name) + if isinstance(val, tuple): + return val[1], val[2] + return pack.tile_fg_color, pack.tile_bg_color def is_wall(self) -> bool: """