dynamic wall drawing
This commit is contained in:
parent
2fae90e071
commit
866c2c14de
4 changed files with 9 additions and 6 deletions
|
|
@ -41,4 +41,5 @@ ACTION_KEYS: Final = {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WALL_CHAR: Final = ord('#')
|
WALL_CHAR: Final = ord('_')
|
||||||
|
VERTICAL_WALL_CHAR: Final = ord('|')
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ from game.components import Action, Gold, Graphic, Position
|
||||||
from game.constants import DIRECTION_KEYS, ACTION_KEYS
|
from game.constants import DIRECTION_KEYS, ACTION_KEYS
|
||||||
from game.screens import Push, Screen, ScreenResult
|
from game.screens import Push, Screen, ScreenResult
|
||||||
from game.tags import IsItem, IsPlayer, IsActor
|
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.screens import menu_screens
|
||||||
from game.world_tools import world_pos_to_map_pos, map_pos_to_world_pos
|
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 (y, row) in enumerate(map.walkable):
|
||||||
for (x, val) in enumerate(row):
|
for (x, val) in enumerate(row):
|
||||||
pos = map_pos_to_world_pos(Position(x,y))
|
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
|
# draw all entities that are not actors
|
||||||
for entity in g.world.Q.all_of(components=[Position, Graphic]).none_of(tags=[IsActor]):
|
for entity in g.world.Q.all_of(components=[Position, Graphic]).none_of(tags=[IsActor]):
|
||||||
draw(entity.components[Position], entity.components[Graphic])
|
draw(entity.components[Position], entity.components[Graphic])
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,6 @@ def new_world() -> Registry:
|
||||||
|
|
||||||
|
|
||||||
def unlock_door(door: Entity):
|
def unlock_door(door: Entity):
|
||||||
door.components[Graphic] = Graphic(ord("_"))
|
door.components[Graphic] = Graphic(ord("/"))
|
||||||
door.components.pop(Action)
|
door.components.pop(Action)
|
||||||
add_wall(g.world, door.components[Position], remove=True)
|
add_wall(g.world, door.components[Position], remove=True)
|
||||||
|
|
|
||||||
2
main.py
2
main.py
|
|
@ -19,7 +19,7 @@ def main() -> None:
|
||||||
#tcod.tileset.procedural_block_elements(tileset=tileset)
|
#tcod.tileset.procedural_block_elements(tileset=tileset)
|
||||||
g.screens = [MainMenu()]
|
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:
|
with tcod.context.new(console=g.console, tileset=tileset) as g.context:
|
||||||
game.screens.main_loop()
|
game.screens.main_loop()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue