Mercurial > nagslang
diff nagslang/game_object.py @ 185:dfacd08b8566
Make FloorSwitchPuzzler are more generic CollidePuzzler
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Tue, 03 Sep 2013 19:48:02 +0200 |
parents | 026297a03963 |
children | d63c19003aec |
line wrap: on
line diff
--- a/nagslang/game_object.py Tue Sep 03 19:31:28 2013 +0200 +++ b/nagslang/game_object.py Tue Sep 03 19:48:02 2013 +0200 @@ -41,11 +41,16 @@ raise NotImplementedError() -class FloorSwitchPuzzler(Puzzler): +class CollidePuzzler(Puzzler): + def __init__(self, *collision_types): + if not collision_types: + collision_types = (COLLISION_TYPE_PLAYER,) + self._collision_types = collision_types + def get_state(self): space = self.game_object.get_space() for shape in space.shape_query(self.game_object.get_shape()): - if shape.collision_type in SWITCH_PUSHERS: + if shape.collision_type in self._collision_types: return True return False @@ -351,7 +356,7 @@ True: resources.get_image('objects', 'sensor_on.png'), False: resources.get_image('objects', 'sensor_off.png'), }), - FloorSwitchPuzzler(), + CollidePuzzler(*SWITCH_PUSHERS), )