Mercurial > mhrok
changeset 27:d0ca7aad951c
Make mobs block movement
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Sat, 10 Mar 2012 10:02:00 +0100 |
| parents | 7864a945fa1b |
| children | 68098f165f4b |
| files | mhrok.py |
| diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mhrok.py Sat Mar 10 09:57:57 2012 +0100 +++ b/mhrok.py Sat Mar 10 10:02:00 2012 +0100 @@ -173,10 +173,14 @@ def walk(self, level, direction): self.direction = direction x, y = self.pos - if not level[x + DX[direction], y + DY[direction]]: + target = x + DX[direction], y + DY[direction] + if not level[target]: return + for mob in level.mobs: + if mob.pos == target: + return self.sprite.set_animation(self.sprite.walk_animation(direction)) - self.pos = x + DX[direction], y + DY[direction] + self.pos = target def control(self, level): keys = pygame.key.get_pressed()
