Minor clean-ups.
authorSimon Cross <hodgestar@gmail.com>
Sat, 5 Mar 2016 14:06:27 +0000 (16:06 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sat, 5 Mar 2016 14:06:27 +0000 (16:06 +0200)
koperkapel/scenes/level.py

index 2ab32c83087fe15d1260fac9b28ca2a7bc322300..fcf99951dee5dbaba0d8daa7fc85790934afadfc 100644 (file)
@@ -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':