clarification

This commit is contained in:
Lukas Nöllemeyer 2024-08-19 20:43:30 +02:00
parent a982e48c11
commit b53ebac2dd
3 changed files with 10 additions and 10 deletions

View file

@ -15,7 +15,7 @@ import g
from game.components import Action, Gold, Graphic, Position
from game.constants import DIRECTION_KEYS, ACTION_KEYS, FLOOR_CHAR
from game.screens import Push, Screen, ScreenResult
from game.tags import IsDoor, IsItem, IsPlayer, IsActor
from game.tags import IsWalllike, IsItem, IsPlayer, IsActor
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
@ -28,11 +28,11 @@ def _handle_movement(player, map, dir):
pos = player.components[Position]
new_pos = pos + dir
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)
if action_entities := g.world.Q.all_of(components=[Action], tags=[new_pos]):
for entity in action_entities:
entity.components[Action](entity)
map_pos = world_pos_to_map_pos(pos)
map.compute_fov(map_pos.x, map_pos.y, 100)
_recalc_fov(map_pos)
return None
if not map.walkable[map_pos.y, map_pos.x]:
return None
@ -62,7 +62,7 @@ def _draw_entity(entity: tcod.ecs.Entity, camera_pos, camera_radius_x, camera_ra
map_pos = world_pos_to_map_pos(pos)
if g.world[None].components[Map].fov[map_pos.y, map_pos.x]:
graphic = entity.components[Graphic]
r,gg,b,a = graphic.fg
r,gg,b,_ = graphic.fg
fg = (r,gg,b,255)
g.foreground.rgba[["ch", "fg"]][screen_pos.y + camera_radius_y, screen_pos.x + camera_radius_x] = graphic.ch, fg
@ -98,7 +98,7 @@ class MainScreen(Screen):
map: Map = g.world[None].components[Map]
# Draw walls and floors
doors = [ d.components[Position] for d in g.world.Q.all_of(tags=[IsDoor]) ]
doors = [ d.components[Position] for d in g.world.Q.all_of(tags=[IsWalllike]) ]
for i in range(console.width):
for j in range(console.height):
world_pos = Position(i-w,j-h)+camera_pos

View file

@ -13,5 +13,5 @@ IsActor: Final = "IsActor"
IsItem: Final = "IsItem"
"""Entity is an item."""
IsDoor: Final = "IsDoor"
IsWalllike: Final = "IsDoor"
"""Entity is a door."""

View file

@ -10,7 +10,7 @@ from tcod.map import Map
import g
from game.components import Action, Gold, Graphic, Position
from game.tags import IsActor, IsItem, IsPlayer, IsDoor
from game.tags import IsActor, IsItem, IsPlayer, IsWalllike
world_center: Final = Position(50, 50)
@ -33,7 +33,7 @@ def add_door(world, pos):
Graphic: Graphic(ord('\\')),
Action: unlock_door
},
tags=[IsDoor]
tags=[IsWalllike]
)
add_wall(world, pos)