3 import pygame.locals as pgl
7 from .base import BaseScene
8 from ..lights import BaseLight
9 from ..obstacles import BaseObstacle
10 from ..events import SceneChangeEvent
11 from ..utils import debug_timer
14 class DayScene(BaseScene):
15 def enter(self, gamestate):
16 self._space = pymunk.Space()
18 BaseObstacle.load(cfg) for cfg in gamestate.station["obstacles"]]
20 BaseLight.load(cfg) for cfg in gamestate.station["lights"]]
21 for obs in self._obstacles:
23 for light in self._lights:
24 light.add(self._space)
26 @debug_timer("day.render")
27 def render(self, surface, gamestate):
28 surface.fill((0, 0, 155))
29 for light in self._lights:
30 light.render_light(surface)
31 for obs in self._obstacles:
33 for light in self._lights:
34 light.render_fittings(surface)
36 def event(self, ev, gamestate):
37 if ev.type == pgl.KEYDOWN:
38 if ev.key in (pgl.K_q, pgl.K_ESCAPE):
39 from .menu import MenuScene
40 SceneChangeEvent.post(scene=MenuScene())
41 elif ev.key == pgl.K_t:
42 for light in self._lights:
45 @debug_timer("day.tick")
46 def tick(self, gamestate):