class BaseLevelScene(Scene):
""" Level scene. """
+ def __init__(self):
+ super().__init__()
+ self._level = None
+
def enter(self, world):
self._level = levels.load(world.level.name)
self._tiles = self._level.tiles
def update(self, world, engine, dt):
"""Fix the door and keypad positions"""
for door in self._doors:
- door.pos = engine.calc_offset(door.game_pos[0] * TILE_SIZE, door.game_pos[1] * TILE_SIZE)
+ door.pos = engine.calc_offset(
+ door.game_pos[0] * TILE_SIZE, door.game_pos[1] * TILE_SIZE)
for keypad in self._keypads:
- keypad.pos = engine.calc_offset(keypad.game_pos[0] * TILE_SIZE, keypad.game_pos[1] * TILE_SIZE)
+ keypad.pos = engine.calc_offset(
+ keypad.game_pos[0] * TILE_SIZE, keypad.game_pos[1] * TILE_SIZE)
def draw(self, screen, viewport):
screen.clear()
screen.surface.blit(self._surfaces[self._level_layer], (0, 0),
area=(viewport[0], viewport[1], WIDTH, HEIGHT))
if self._level_layer != 'floor':
- screen.surface.blit(self._overlay, (0, 0),
- area=(viewport[0], viewport[1], WIDTH, HEIGHT),
- special_flags=pgl.BLEND_MULT)
+ screen.surface.blit(
+ self._overlay, (0, 0),
+ area=(viewport[0], viewport[1], WIDTH, HEIGHT),
+ special_flags=pgl.BLEND_MULT)
self.actors.draw(screen)
def on_key_down(self, key, mod, unicode):
self._avatar.pos = (WIDTH // 2, HEIGHT // 2)
self._roaches.add(self._avatar)
# Fix viewport offset
- return [MoveViewportEvent((x * TILE_SIZE - WIDTH // 2, y * TILE_SIZE - HEIGHT // 2))]
+ return [
+ MoveViewportEvent((
+ x * TILE_SIZE - WIDTH // 2,
+ y * TILE_SIZE - HEIGHT // 2))]
def _set_pos(self, x, y):
self._player_pos = (x, y)
- print('Now at ', x, y)
def _can_move(self, x, y):
if self._mode == 'walk':