Tile colors can be overwritten
This commit is contained in:
parent
9a56b4d7e9
commit
6b7f8867fa
@ -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()],
|
||||
|
@ -91,7 +91,7 @@ TexturePack.SQUIRREL_PACK = TexturePack(
|
||||
EMPTY=' ',
|
||||
EXPLOSION='💥',
|
||||
FLOOR='██',
|
||||
LADDER='🪜',
|
||||
LADDER=('🪜', curses.COLOR_WHITE, curses.COLOR_WHITE),
|
||||
HAZELNUT='🌰',
|
||||
HEART='💜',
|
||||
HEDGEHOG='🦔',
|
||||
|
@ -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:
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user