fixed camera
Co-authored-by: staubsauger <staubsauger@users.noreply.github.com>
This commit is contained in:
parent
d82e76e6d4
commit
0ea61c91b5
1 changed files with 3 additions and 3 deletions
|
|
@ -54,14 +54,14 @@ class InGame(State):
|
||||||
centers = g.world.Q.all_of(tags=[IsPlayer])
|
centers = g.world.Q.all_of(tags=[IsPlayer])
|
||||||
centers = list(map(lambda a: a.components[Position], centers))
|
centers = list(map(lambda a: a.components[Position], centers))
|
||||||
center = reduce(lambda a,b: a.components[Position]+b.components[Position], centers)
|
center = reduce(lambda a,b: a.components[Position]+b.components[Position], centers)
|
||||||
center.mod(len(centers))
|
center = center.mod(len(centers))
|
||||||
|
|
||||||
def draw(e):
|
def draw(e):
|
||||||
pos = Position(console.width//2, console.height//2) + center - e.components[Position]
|
pos = e.components[Position] - center
|
||||||
if (-console.width//2 <= pos.x < console.width//2\
|
if (-console.width//2 <= pos.x < console.width//2\
|
||||||
and -console.height//2 <= pos.y < console.height//2):
|
and -console.height//2 <= pos.y < console.height//2):
|
||||||
graphic = e.components[Graphic]
|
graphic = e.components[Graphic]
|
||||||
console.rgb[["ch", "fg"]][pos.y, pos.x] = graphic.ch, graphic.fg
|
console.rgb[["ch", "fg"]][pos.y + console.height//2, pos.x + console.width//2] = graphic.ch, graphic.fg
|
||||||
|
|
||||||
for entity in g.world.Q.all_of(components=[Position, Graphic]).none_of(tags=[IsActor]):
|
for entity in g.world.Q.all_of(components=[Position, Graphic]).none_of(tags=[IsActor]):
|
||||||
draw(entity)
|
draw(entity)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue