small drawing change

This commit is contained in:
Lukas Nöllemeyer 2024-08-17 13:15:44 +02:00
parent bbc958b36c
commit 4e5005523b

View file

@ -67,7 +67,10 @@ class MainScreen(Screen):
w = console.width//2
map: Map = g.world[None].components[Map]
# TODO: eigentlich wäre andersrum rendern schöner
# also nicht alle objekte zu rendern und dabei rauszufinden ob sie auf dem screen sind,
# sondern über alle screen zellen laufen, über prüfen ob es im fov ist und dann gucken ob es dort ein objekt
# gibt und es entsprechend rendern
def draw(e_pos, e_graph):
screen_pos = e_pos - camera_pos
map_pos = world_pos_to_map_pos(e_pos)
@ -77,16 +80,14 @@ class MainScreen(Screen):
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
if graphic.ch != 0:
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):
pos = map_pos_to_world_pos(Position(x,y))
if val:
draw(pos, Graphic(0)) # open air
else:
draw(pos, Graphic(WALL_CHAR))
draw(pos, Graphic(0) if val else 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])