self._app = app
self._scene = scene
self._world = world
- self._viewport = (0, 0)
def _apply_events(self, events):
if not events:
exit()
def move_screen(self, offset):
- self._viewport = (self._viewport[0] + offset[0],
- self._viewport[1] + offset[1])
-
- def calc_offset(self, x, y):
- """Return a position offset by the viewport"""
- return x - self._viewport[0], y - self._viewport[1]
+ self._scene.move_screen(offset)
@apply_events
def update(self, dt):
return self._scene.update(self._world.proxy(), self, dt)
def draw(self):
- self._scene.draw(self._app.screen, self._viewport)
+ self._scene.draw(self._app.screen)
@apply_events
def on_mouse_down(self, pos, button):
def __init__(self):
self.actors = Actors()
+ self.viewport = (0, 0)
+
+ def move_screen(self, offset):
+ self.viewport = (self.viewport[0] + offset[0],
+ self.viewport[1] + offset[1])
+
+ def calc_offset(self, x, y):
+ """ Return a position offset by the viewport. """
+ return x - self.viewport[0], y - self.viewport[1]
def enter(self, world):
pass
def update(self, world, engine, dt):
pass
- def draw(self, screen, viewport):
+ def draw(self, screen):
screen.clear()
self.actors.draw(screen)
class CreditsScene(Scene):
""" Credits scene. """
- def draw(self, screen, viewport):
+ def draw(self, screen):
screen.clear()
screen.draw.text("Credits", (300, 300))
def update(self, world, engine, dt):
"""Fix the door and keypad positions"""
for door in self._doors:
- door.pos = engine.calc_offset(
+ door.pos = self.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.pos = self.calc_offset(
keypad.game_pos[0] * TILE_SIZE, keypad.game_pos[1] * TILE_SIZE)
- def draw(self, screen, viewport):
+ def draw(self, screen):
screen.clear()
# 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
+ viewport = self.viewport
screen.surface.blit(self._surfaces[self._level_layer], (0, 0),
area=(viewport[0], viewport[1], WIDTH, HEIGHT))
if self._level_layer != 'floor':
from pgzero.constants import keys, mouse
from pgzero.actor import Actor
+from pgzero.screen import Screen
from ..actors.buttons import ImageButton
+from ..actors.surf import SurfActor
from ..constants import WIDTH, HEIGHT
from ..roaches import big_roaches, roach_by_name
from ..serums import big_serums, roach_is_serumless, SERUMS
def _init_bg(self):
self.actors.default.clear()
- self.actors.default.add(self._vehicle.roach_management_overlay())
+ overlay = self._vehicle.roach_management_overlay()._surf
+ base = overlay.copy()
+ if self._level_scene is not None:
+ base.fill((0, 0, 0))
+ self._level_scene.draw(Screen(base))
+ else:
+ base.fill((10, 10, 10))
+ base.blit(overlay, (0, 0))
+ self.actors.default.add(SurfActor(base))
def _init_seats(self):
self._seat_layer.clear()