1 """ In the night, the mould attacks. """
3 import pygame.locals as pgl
7 from .base import BaseScene
8 from ..lights import LightManager
9 from ..obstacles import ObstacleManager
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()
18 self._obstacles = ObstacleManager(self._space, gamestate)
19 self._lights = LightManager(self._space, gamestate)
20 self._mould = Boyd(gamestate, self._space)
22 @debug_timer("night.render")
23 def render(self, surface, gamestate):
24 surface.fill((0, 0, 155))
25 self._mould.render(surface)
26 self._lights.render_light(surface)
27 self._obstacles.render(surface)
28 self._lights.render_fittings(surface)
30 def event(self, ev, gamestate):
31 if ev.type == pgl.KEYDOWN:
32 if ev.key in (pgl.K_q, pgl.K_ESCAPE):
33 from .menu import MenuScene
34 SceneChangeEvent.post(scene=MenuScene())
36 from .day import DayScene
37 SceneChangeEvent.post(scene=DayScene())
38 elif ev.type == pgl.MOUSEBUTTONDOWN:
40 self._lights.toggle_nearest(ev.pos, surfpos=True)
41 print self._lights.lit_by(ev.pos, surfpos=True)
43 @debug_timer("night.tick")
44 def tick(self, gamestate):
45 self._mould.tick(gamestate, self._space, self._lights)