Hack'ish rendering of walls
[tabakrolletjie.git] / tabakrolletjie / scenes / night.py
1 """ In the night, the mould attacks. """
2
3 import pygame.locals as pgl
4
5 import pymunk
6
7 from .base import BaseScene
8 from ..obstacles import Wall
9 from ..events import SceneChangeEvent
10
11
12 class NightScene(BaseScene):
13     def enter(self, gamestate):
14         import pprint
15         pprint.pprint(gamestate.station)
16
17         self._space = pymunk.Space()
18
19         self._obstacles = []
20         self._lights = []
21         for obs in gamestate.station['obstacles']:
22             wall = Wall(obs['vertices'], self._space)
23             self._obstacles.append(wall)
24
25     def render(self, surface, gamestate):
26         surface.fill((0, 0, 255))
27         for obs in self._obstacles:
28             obs.render(surface)
29
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())