comparison mamba/engine.py @ 559:4c30776673c6

Don't use 'is' to compare ints -- it's dangerous.
author Simon Cross <hodgestar@gmail.com>
date Sat, 08 Oct 2011 20:24:03 +0200
parents c014f5023cd2
children
comparison
equal deleted inserted replaced
558:73c4985bf726 559:4c30776673c6
28 flip = pygame.display.flip 28 flip = pygame.display.flip
29 clock = pygame.time.Clock() 29 clock = pygame.time.Clock()
30 while True: 30 while True:
31 events = get_events() 31 events = get_events()
32 for ev in events: 32 for ev in events:
33 if ev.type is QUIT: 33 if ev.type == QUIT:
34 return 34 return
35 elif NewHabitatEvent.matches(ev): 35 elif NewHabitatEvent.matches(ev):
36 self.set_habitat(ev.habitat) 36 self.set_habitat(ev.habitat)
37 else: 37 else:
38 self._habitat.dispatch(ev) 38 self._habitat.dispatch(ev)
88 ev = pygame.event.Event(USEREVENT, utype=cls.TYPE, **kws) 88 ev = pygame.event.Event(USEREVENT, utype=cls.TYPE, **kws)
89 pygame.event.post(ev) 89 pygame.event.post(ev)
90 90
91 @classmethod 91 @classmethod
92 def matches(cls, ev): 92 def matches(cls, ev):
93 return ev.type is USEREVENT and ev.utype == cls.TYPE 93 return ev.type == USEREVENT and ev.utype == cls.TYPE
94 94
95 95
96 class NewHabitatEvent(UserEvent): 96 class NewHabitatEvent(UserEvent):
97 97
98 TYPE = "NEW_HABITAT" 98 TYPE = "NEW_HABITAT"