From 0026e22c02a2373b7857ed06d69f1ceaf8d27ea1 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sat, 5 Mar 2016 16:06:27 +0200 Subject: [PATCH] Minor clean-ups. --- koperkapel/scenes/level.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/koperkapel/scenes/level.py b/koperkapel/scenes/level.py index 2ab32c8..fcf9995 100644 --- a/koperkapel/scenes/level.py +++ b/koperkapel/scenes/level.py @@ -12,6 +12,10 @@ from ..vehicles.base import Vehicle 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 @@ -48,9 +52,11 @@ class BaseLevelScene(Scene): 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() @@ -60,9 +66,10 @@ class BaseLevelScene(Scene): 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): @@ -89,11 +96,13 @@ class GameLevelScene(BaseLevelScene): 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': -- 2.34.1