Mercurial > pavulon
changeset 37:26cb0dbf6af1
pushing things around
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Sat, 10 Sep 2011 11:08:57 +0200 |
| parents | 9dc78f2fcca4 |
| children | e3900622d58d |
| files | level.map qq.py |
| diffstat | 2 files changed, 21 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/level.map Sat Sep 10 10:25:25 2011 +0200 +++ b/level.map Sat Sep 10 11:08:57 2011 +0200 @@ -1,7 +1,7 @@ [level] tileset = hospital.png map = ###.########### - #.>.....x.x.x.# + #.......x.x.x.# #......x.x.h.## #...@.......x.# #......s...x.## @@ -35,13 +35,8 @@ name = baby tile = 1, 3 sprite = baby.png -block = true monster = true -[>] -name = stairs -tile = 3, 3 - [b] name = firstaid tile = 1, 3 @@ -51,10 +46,8 @@ name = bed tile = 1, 3 sprite = bed.png -block = true [x] name = barell tile = 1, 3 sprite = barell.png -block = true
--- a/qq.py Sat Sep 10 10:25:25 2011 +0200 +++ b/qq.py Sat Sep 10 11:08:57 2011 +0200 @@ -129,12 +129,11 @@ def stand_animation(self): """The default animation.""" - while True: - # Change to next frame every two ticks - for frame in self.frames[0]: - self.image = frame - yield None - yield None + # Change to next frame every two ticks + for frame in self.frames[0]: + self.image = frame + yield None + yield None def update(self, *args): """Run the current animation.""" @@ -153,15 +152,17 @@ Sprite.__init__(self, pos, frames) self.direction = 2 - def ai(self, level): + def go(self, level, direction): x, y = self.pos - self.direction = 2 + self.direction = direction dx, dy = DX[self.direction], DY[self.direction] if level.is_blocking(x + dx, y + dy): - return + return False self.pos = x + dx, y + dy + for frame in self.animation: + pass self.animation = self.walk_animation() - return self.direction + return True def walk_animation(self): """Animation for the monster walking.""" @@ -376,10 +377,16 @@ """Start walking in specified direction.""" x, y = self.player.pos + pos = x + DX[d], y + DY[d] self.player.direction = d - if not self.level.is_blocking(x+DX[d], y+DY[d]): - self.player.animation = self.player.walk_animation() - self.player.pos = (x+DX[d], y+DY[d]) + if self.level.is_blocking(*pos): + return + for monster in self.monsters: + if monster.pos == pos: + if not monster.go(self.level, d): + return + self.player.animation = self.player.walk_animation() + self.player.pos = pos if pressed(pg.K_UP): walk(0) @@ -408,8 +415,6 @@ if self.player.animation is None: self.control() self.player.update() - for monster in self.monsters: - monster.ai(self.level) self.shadows.update() # Don't add shadows to dirty rectangles, as they already fit inside # sprite rectangles.
