enhanced FOV

This commit is contained in:
Lukas Nöllemeyer 2024-08-17 12:28:39 +02:00
parent 0a0ff2d1ed
commit 1bd0ab372d
4 changed files with 20 additions and 15 deletions

View file

@ -64,18 +64,23 @@ class MainScreen(Screen):
def draw(e_pos, e_graph):
screen_pos = e_pos - camera_pos
mp = world_pos_to_map_pos(e_pos)
map_pos = world_pos_to_map_pos(e_pos)
if (-w <= screen_pos.x < w\
and -h <= screen_pos.y < h)\
and map.fov[mp.y][mp.x]:
graphic = e_graph
and -h <= screen_pos.y < h):
if map.fov[map_pos.y][map_pos.x]:
graphic = e_graph
else:
graphic = Graphic(0x2591, (50, 50, 50))
console.rgb[["ch", "fg"]][screen_pos.y + h, screen_pos.x + w] = graphic.ch, graphic.fg
# Draw walls
for (y, row) in enumerate(map.walkable):
for (x, val) in enumerate(row):
if not val:
draw(map_pos_to_world_pos(Position(x,y)), Graphic(WALL_CHAR))
pos = map_pos_to_world_pos(Position(x,y))
if val:
draw(pos, Graphic(0)) # open air
else:
draw(pos, Graphic(WALL_CHAR))
# 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])