3 import pygame.locals as pgl
8 from .base import BaseScene
9 from ..lights import BaseLight
10 from ..obstacles import BaseObstacle
11 from ..events import SceneChangeEvent
13 from ..constants import DEBUG
16 class DayScene(BaseScene):
17 def enter(self, gamestate):
18 self._space = pymunk.Space()
20 BaseObstacle.load(cfg) for cfg in gamestate.station["obstacles"]]
22 BaseLight.load(cfg) for cfg in gamestate.station["lights"]]
23 for obs in self._obstacles:
25 for light in self._lights:
26 light.add(self._space)
28 def render(self, surface, gamestate):
29 start_time = time.time()
30 surface.fill((0, 0, 155))
31 for light in self._lights:
32 light.render_light(surface)
33 for obs in self._obstacles:
35 for light in self._lights:
36 light.render_fittings(surface)
38 end_time = time.time()
40 print "Day Render", end_time - start_time
42 def event(self, ev, gamestate):
43 if ev.type == pgl.KEYDOWN:
44 if ev.key in (pgl.K_q, pgl.K_ESCAPE):
45 from .menu import MenuScene
46 SceneChangeEvent.post(scene=MenuScene())
47 elif ev.key == pgl.K_t:
48 for light in self._lights:
51 def tick(self, gamestate):
52 start_time = time.time()
53 end_time = time.time()
55 print "Day Tick", end_time - start_time