From 0ea61c91b5a9504132e4b8933ee581f869a7bf17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20N=C3=B6llemeyer?= Date: Fri, 16 Aug 2024 22:48:27 +0200 Subject: [PATCH] fixed camera Co-authored-by: staubsauger --- game/states.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/game/states.py b/game/states.py index 3d30a08..22a14a9 100644 --- a/game/states.py +++ b/game/states.py @@ -54,14 +54,14 @@ class InGame(State): centers = g.world.Q.all_of(tags=[IsPlayer]) centers = list(map(lambda a: a.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): - 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\ and -console.height//2 <= pos.y < console.height//2): 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]): draw(entity)