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)