Changeset 224:b6db213e53a2


Ignore:
Timestamp:
Sep 4, 2013, 3:25:26 PM (7 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Message:

Bulkheads are bits of wall you can walk through.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • data/levels/level1

    r209 r224  
    5151  - Run around, press some buttons, have fun!
    5252  classname: Note
     53- args:
     54  - [800, 680]
     55  - [900, 680]
     56  - door_switch
     57  classname: Bulkhead
     58  name: switch_bulkhead
    5359lines:
    5460- - [750, 680]
     61  - [800, 680]
     62- - [900, 680]
    5563  - [950, 680]
    5664- - [750, 480]
  • nagslang/game_object.py

    r222 r224  
    221221        if self.puzzler.get_state():
    222222            DoorEvent.post(self.destination, self.dest_pos)
     223
     224
     225class Bulkhead(GameObject):
     226    zorder = ZORDER_FLOOR
     227
     228    def __init__(self, space, end1, end2, key_state=None):
     229        body = make_body(None, None, (0, 0))
     230        self.shape = pymunk.Segment(body, tuple(end1), tuple(end2), 3)
     231        self.shape.collision_type = COLLISION_TYPE_DOOR
     232        if key_state is None:
     233            puzzler = puzzle.YesPuzzler()
     234        else:
     235            puzzler = puzzle.StateProxyPuzzler(key_state)
     236        super(Bulkhead, self).__init__(
     237            SingleShapePhysicser(space, self.shape),
     238            render.ShapeStateRenderer(),
     239            puzzler,
     240        )
     241
     242    def collide_with_protagonist(self):
     243        if self.puzzler.get_state():
     244            # Reject the collision, we can walk through.
     245            return False
     246        return True
Note: See TracChangeset for help on using the changeset viewer.