From: Neil Date: Sat, 5 Mar 2016 06:23:12 +0000 (+0200) Subject: Center display around our hero(es) X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=8dadf9accd2b841312131667c69f4a801fb93782;p=koperkapel.git Center display around our hero(es) --- diff --git a/koperkapel/scenes/level.py b/koperkapel/scenes/level.py index a800ba0..9dd8b61 100644 --- a/koperkapel/scenes/level.py +++ b/koperkapel/scenes/level.py @@ -62,16 +62,18 @@ class GameLevelScene(BaseLevelScene): def enter(self, world): super().enter(world) self._roaches = self.actors.add_layer("roaches", level=10) - self._init_roaches(world.roaches) + return self._init_roaches(world.roaches) def _init_roaches(self, roaches): - x, y = self._level.start_pos for roach in roaches: roach_actor = self._roaches.add(default_roaches.assemble(roach)) roach_actor.anchor = (0, 0) - roach_actor.pos = (x * TILE_SIZE, y * TILE_SIZE) + roach_actor.pos = (WIDTH // 2, HEIGHT // 2) + x, y = self._level.start_pos self._set_pos(x, y) self._level_layer = 'floor' + # Fix viewport offset + return [MoveViewportEvent((x * TILE_SIZE - WIDTH // 2, y * TILE_SIZE - HEIGHT // 2))] def _set_pos(self, x, y): self._player_pos = (x, y)