import pygame.locals as pgl
from ..loaders.levelloader import levels
from .base import Scene, ChangeSceneEvent
-from ..constants import TILE_SIZE
+from ..constants import TILE_SIZE, WIDTH, HEIGHT
-class LevelScene(Scene):
+class BaseLevelScene(Scene):
""" Level scene. """
def enter(self, world):
# Viewport is the position of the screen relative to the
# surface. We need the position of the surface relative to
# the screen for the blit, so this conversion
- screen_pos = -viewport[0], -viewport[1]
- if self._level_layer == 'floor':
- screen.blit(self._surfaces[self._level_layer], screen_pos)
- else:
- # blit tunnels, with translucent overlay
- # We need to call pygame.Surface.blit ourselves,
- # since pgzero's screen blit hides the blend flags
- # from us
- tunnels = self._surfaces[self._level_layer].copy()
- tunnels.blit(self._overlay, (0, 0),
- special_flags=pgl.BLEND_MULT)
- screen.blit(tunnels, screen_pos)
+ 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_ADD)
def on_key_down(self, key, mod, unicode):
if key == keys.ESCAPE:
from .menu import MenuScene
return [ChangeSceneEvent(MenuScene())]
+
+
+class GameLevelScene(BaseLevelScene):
+ pass
"""Render a level and allow moving the scene"""
from pgzero.constants import keys
-from .level import LevelScene
+from .level import BaseLevelScene
from .base import MoveViewportEvent
from ..constants import TILE_SIZE
-class ViewLevelScene(LevelScene):
+class ViewLevelScene(BaseLevelScene):
""" Level scene. """
def on_key_down(self, key, mod, unicode):