Mercurial > nagslang
comparison nagslang/game_object.py @ 180:026297a03963
Add DoorEvent and tweak ScreenChange to keep more state when the player goes through a door
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Tue, 03 Sep 2013 16:58:45 +0200 |
parents | 054944c6472b |
children | dfacd08b8566 |
comparison
equal
deleted
inserted
replaced
179:1ee8756888e4 | 180:026297a03963 |
---|---|
7 from nagslang.constants import ( | 7 from nagslang.constants import ( |
8 SWITCH_PUSHERS, COLLISION_TYPE_SWITCH, COLLISION_TYPE_BOX, ZORDER_LOW, | 8 SWITCH_PUSHERS, COLLISION_TYPE_SWITCH, COLLISION_TYPE_BOX, ZORDER_LOW, |
9 ZORDER_FLOOR, COLLISION_TYPE_DOOR, COLLISION_TYPE_PLAYER) | 9 ZORDER_FLOOR, COLLISION_TYPE_DOOR, COLLISION_TYPE_PLAYER) |
10 from nagslang.options import options | 10 from nagslang.options import options |
11 from nagslang.resources import resources | 11 from nagslang.resources import resources |
12 from nagslang.events import ScreenChange | 12 from nagslang.events import DoorEvent |
13 | 13 |
14 | 14 |
15 class PuzzleGlue(object): | 15 class PuzzleGlue(object): |
16 """Glue that holds bits of a puzzle together. | 16 """Glue that holds bits of a puzzle together. |
17 """ | 17 """ |
404 def animate(self): | 404 def animate(self): |
405 space = self.get_space() | 405 space = self.get_space() |
406 for shape in space.shape_query(self.get_shape()): | 406 for shape in space.shape_query(self.get_shape()): |
407 if shape.collision_type == COLLISION_TYPE_PLAYER: | 407 if shape.collision_type == COLLISION_TYPE_PLAYER: |
408 # Force to new position | 408 # Force to new position |
409 shape.body.position = self.dest_pos | 409 DoorEvent.post(self.destination, self.dest_pos) |
410 ScreenChange.post(self.destination) |