source: nagslang/screens/base.py

Last change on this file was 557:943d93b47c77, checked in by Stefano Rivera <stefano@…>, 8 years ago

Ignore the pymunk AssertionError on level change

File size: 929 bytes
Line 
1"""A screen or area in which action happens."""
2
3import sys
4
5from pygame import event
6import pymunk
7
8
9class Screen(object):
10
11 def __init__(self, name, world):
12 self.name = name
13 self.world = world
14 self.space = pymunk.Space()
15
16 def setup(self):
17 """Perform setup based on the world state."""
18 pass
19
20 def teardown(self):
21 pass
22
23 def post_event(self, ev):
24 event.post(ev)
25
26 def handle_event(self, ev):
27 pass
28
29 def render(self, surface):
30 pass
31
32 def tick(self, seconds):
33 """Step the given amount of time."""
34 try:
35 self.space.step(seconds)
36 except AssertionError:
37 # TODO: Find the source of these
38 print >> sys.stderr, (
39 'Caught a pymunk assertion error. '
40 "We don't know what causes these on level change. "
41 "Hopefully we can ignore them...")
Note: See TracBrowser for help on using the repository browser.