+import pymunk
+import pymunk.pygame_util
+import pygame.draw
+
+
+class Wall(object):
+
+ def __init__(self, vertices, space):
+ body = pymunk.Body(0, 0, pymunk.body.Body.STATIC)
+ self._shape = pymunk.Poly(body, vertices)
+ space.add(self._shape)
+
+ def render(self, surface):
+ pygame_poly = [pymunk.pygame_util.to_pygame(v, surface) for v in
+ self._shape.get_vertices()]
+ pygame.draw.polygon(surface, (0, 0, 0), pygame_poly)
import pygame.locals as pgl
+import pymunk
+
from .base import BaseScene
+from ..obstacles import Wall
from ..events import SceneChangeEvent
import pprint
pprint.pprint(gamestate.station)
+ self._space = pymunk.Space()
+
+ self._obstacles = []
+ self._lights = []
+ for obs in gamestate.station['obstacles']:
+ wall = Wall(obs['vertices'], self._space)
+ self._obstacles.append(wall)
+
def render(self, surface, gamestate):
surface.fill((0, 0, 255))
+ for obs in self._obstacles:
+ obs.render(surface)
def event(self, ev, gamestate):
if ev.type == pgl.KEYDOWN: