Mercurial > nagslang
changeset 224:b6db213e53a2
Bulkheads are bits of wall you can walk through.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Wed, 04 Sep 2013 17:25:26 +0200 |
parents | 4197350b9897 |
children | c8ead015c48e |
files | data/levels/level1 nagslang/game_object.py |
diffstat | 2 files changed, 32 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/data/levels/level1 Wed Sep 04 16:56:24 2013 +0200 +++ b/data/levels/level1 Wed Sep 04 17:25:26 2013 +0200 @@ -50,8 +50,16 @@ - [290, 160] - Run around, press some buttons, have fun! classname: Note +- args: + - [800, 680] + - [900, 680] + - door_switch + classname: Bulkhead + name: switch_bulkhead lines: - - [750, 680] + - [800, 680] +- - [900, 680] - [950, 680] - - [750, 480] - [950, 480]
--- a/nagslang/game_object.py Wed Sep 04 16:56:24 2013 +0200 +++ b/nagslang/game_object.py Wed Sep 04 17:25:26 2013 +0200 @@ -220,3 +220,27 @@ def collide_with_protagonist(self): if self.puzzler.get_state(): DoorEvent.post(self.destination, self.dest_pos) + + +class Bulkhead(GameObject): + zorder = ZORDER_FLOOR + + def __init__(self, space, end1, end2, key_state=None): + body = make_body(None, None, (0, 0)) + self.shape = pymunk.Segment(body, tuple(end1), tuple(end2), 3) + self.shape.collision_type = COLLISION_TYPE_DOOR + if key_state is None: + puzzler = puzzle.YesPuzzler() + else: + puzzler = puzzle.StateProxyPuzzler(key_state) + super(Bulkhead, self).__init__( + SingleShapePhysicser(space, self.shape), + render.ShapeStateRenderer(), + puzzler, + ) + + def collide_with_protagonist(self): + if self.puzzler.get_state(): + # Reject the collision, we can walk through. + return False + return True