dynamic wall drawing

This commit is contained in:
Lukas Nöllemeyer 2024-08-17 15:58:48 +02:00
parent 2fae90e071
commit 866c2c14de
4 changed files with 9 additions and 6 deletions

View file

@ -41,4 +41,5 @@ ACTION_KEYS: Final = {
}
WALL_CHAR: Final = ord('#')
WALL_CHAR: Final = ord('_')
VERTICAL_WALL_CHAR: Final = ord('|')

View file

@ -14,7 +14,7 @@ from game.components import Action, Gold, Graphic, Position
from game.constants import DIRECTION_KEYS, ACTION_KEYS
from game.screens import Push, Screen, ScreenResult
from game.tags import IsItem, IsPlayer, IsActor
from game.constants import WALL_CHAR
from game.constants import WALL_CHAR, VERTICAL_WALL_CHAR
from game.screens import menu_screens
from game.world_tools import world_pos_to_map_pos, map_pos_to_world_pos
@ -94,7 +94,9 @@ class MainScreen(Screen):
for (y, row) in enumerate(map.walkable):
for (x, val) in enumerate(row):
pos = map_pos_to_world_pos(Position(x,y))
draw(pos, Graphic(0) if val else Graphic(WALL_CHAR))
graphic = Graphic(0) if val else\
Graphic(WALL_CHAR) if map.walkable[y+1,x] else Graphic(VERTICAL_WALL_CHAR)
draw(pos, graphic)
# draw all entities that are not actors
for entity in g.world.Q.all_of(components=[Position, Graphic]).none_of(tags=[IsActor]):
draw(entity.components[Position], entity.components[Graphic])

View file

@ -83,6 +83,6 @@ def new_world() -> Registry:
def unlock_door(door: Entity):
door.components[Graphic] = Graphic(ord("_"))
door.components[Graphic] = Graphic(ord("/"))
door.components.pop(Action)
add_wall(g.world, door.components[Position], remove=True)

View file

@ -15,11 +15,11 @@ from game.screens.menu_screens import MainMenu
def main() -> None:
"""Entry point function."""
tileset = game.tilesetmanager.valid_tileset()
#tcod.tileset.procedural_block_elements(tileset=tileset)
g.screens = [MainMenu()]
g.console = tcod.console.Console(80, 50)
g.console = tcod.console.Console(80, 35)
with tcod.context.new(console=g.console, tileset=tileset) as g.context:
game.screens.main_loop()