1 """ In the night, the mould attacks. """
3 import pygame.locals as pgl
8 from .base import BaseScene
9 from ..lights import BaseLight
10 from ..obstacles import BaseObstacle
11 from ..enemies import Boyd
12 from ..events import SceneChangeEvent
14 from ..constants import DEBUG
17 class NightScene(BaseScene):
18 def enter(self, gamestate):
19 self._space = pymunk.Space()
21 BaseObstacle.load(cfg) for cfg in gamestate.station["obstacles"]]
23 BaseLight.load(cfg) for cfg in gamestate.station["lights"]]
24 for obs in self._obstacles:
26 for light in self._lights:
27 light.add(self._space)
29 self._mould = Boyd(gamestate, self._space)
31 def render(self, surface, gamestate):
32 start_time = time.time()
33 surface.fill((0, 0, 155))
34 for light in self._lights:
35 light.render_light(surface)
36 for obs in self._obstacles:
38 for light in self._lights:
40 self._mould.render(surface)
42 end_time = time.time()
44 print "Night Render", end_time - start_time
46 def event(self, ev, gamestate):
47 if ev.type == pgl.KEYDOWN:
48 if ev.key in (pgl.K_q, pgl.K_ESCAPE):
49 from .menu import MenuScene
50 SceneChangeEvent.post(scene=MenuScene())
52 def tick(self, gamestate):
53 start_time = time.time()
54 self._mould.tick(gamestate, self._space)
55 end_time = time.time()
57 print "Night Tick", end_time - start_time