1 """ In the night, the mould attacks. """
3 import pygame.locals as pgl
7 from .base import BaseScene
8 from ..lights import BaseLight
9 from ..obstacles import BaseObstacle
10 from ..enemies import Boyd
11 from ..events import SceneChangeEvent
12 from ..utils import debug_timer
15 class NightScene(BaseScene):
16 def enter(self, gamestate):
17 self._space = pymunk.Space()
19 BaseObstacle.load(cfg) for cfg in gamestate.station["obstacles"]]
21 BaseLight.load(cfg) for cfg in gamestate.station["lights"]]
22 for obs in self._obstacles:
24 for light in self._lights:
25 light.add(self._space)
27 self._mould = Boyd(gamestate, self._space)
29 @debug_timer("night.render")
30 def render(self, surface, gamestate):
31 surface.fill((0, 0, 155))
32 for light in self._lights:
33 light.render_light(surface)
34 for obs in self._obstacles:
36 for light in self._lights:
37 light.render_fittings(surface)
38 self._mould.render(surface)
40 def event(self, ev, gamestate):
41 if ev.type == pgl.KEYDOWN:
42 if ev.key in (pgl.K_q, pgl.K_ESCAPE):
43 from .menu import MenuScene
44 SceneChangeEvent.post(scene=MenuScene())
45 elif ev.key == pgl.K_t:
46 for light in self._lights:
49 @debug_timer("night.tick")
50 def tick(self, gamestate):
51 self._mould.tick(gamestate, self._space)