made walking into doors open them

This commit is contained in:
Lukas Nöllemeyer 2024-08-17 15:04:05 +02:00
parent 091ff11b6d
commit eaa19304e1

View file

@ -38,8 +38,15 @@ class MainScreen(Screen):
case tcod.event.Quit():
raise SystemExit()
case tcod.event.KeyDown(sym=sym) if sym in DIRECTION_KEYS:
new_pos = player.components[Position] + DIRECTION_KEYS[sym]
pos = player.components[Position]
new_pos = pos + DIRECTION_KEYS[sym]
map_pos = world_pos_to_map_pos(new_pos)
if a := g.world.Q.all_of(components=[Action], tags=[new_pos]):
for aa in a:
aa.components[Action](aa)
map_pos = world_pos_to_map_pos(pos)
map.compute_fov(map_pos.x, map_pos.y, 100)
return None
if not map.walkable[map_pos.y, map_pos.x]:
return None
player.components[Position] = new_pos