1 """Render a level and allow moving the scene"""
3 from pgzero.constants import keys
4 from .level import LevelScene
5 from .base import MoveViewportEvent
6 from ..constants import TILE_SIZE
9 class ViewLevelScene(LevelScene):
12 def on_key_down(self, key, mod, unicode):
15 offset = (0, TILE_SIZE)
17 offset = (0, -TILE_SIZE)
18 elif key == keys.LEFT:
19 offset = (-TILE_SIZE, 0)
20 elif key == keys.RIGHT:
21 offset = (TILE_SIZE, 0)
23 if self._level_layer == 'floor':
24 self._level_layer = 'tunnels'
26 self._level_layer = 'floor'
29 return [MoveViewportEvent(offset)]
30 return super(ViewLevelScene, self).on_key_down(key, mod, unicode)