small drawing change
This commit is contained in:
parent
bbc958b36c
commit
4e5005523b
1 changed files with 7 additions and 6 deletions
|
|
@ -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))
|
||||
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])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue