Changeset 185:dfacd08b8566


Ignore:
Timestamp:
Sep 3, 2013, 5:48:02 PM (7 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Message:

Make FloorSwitchPuzzler? are more generic CollidePuzzler?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/game_object.py

    r180 r185  
    4242
    4343
    44 class FloorSwitchPuzzler(Puzzler):
     44class CollidePuzzler(Puzzler):
     45    def __init__(self, *collision_types):
     46        if not collision_types:
     47            collision_types = (COLLISION_TYPE_PLAYER,)
     48        self._collision_types = collision_types
     49
    4550    def get_state(self):
    4651        space = self.game_object.get_space()
    4752        for shape in space.shape_query(self.game_object.get_shape()):
    48             if shape.collision_type in SWITCH_PUSHERS:
     53            if shape.collision_type in self._collision_types:
    4954                return True
    5055        return False
     
    352357                False: resources.get_image('objects', 'sensor_off.png'),
    353358            }),
    354             FloorSwitchPuzzler(),
     359            CollidePuzzler(*SWITCH_PUSHERS),
    355360        )
    356361
Note: See TracChangeset for help on using the changeset viewer.