Mercurial > scrounge
changeset 8:e1209ce6e267
added doors
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Sun, 21 Aug 2011 19:13:26 +0200 |
| parents | 16ed0655c148 |
| children | e90e639d45f9 |
| files | display.py hero.py level.py objects.png thing.py |
| diffstat | 5 files changed, 24 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/display.py Sun Aug 21 18:45:26 2011 +0200 +++ b/display.py Sun Aug 21 19:13:26 2011 +0200 @@ -47,12 +47,13 @@ class Sprite(pygame.sprite.Sprite): - def __init__(self, x, y, filename): + def __init__(self, x, y, filename, tx=0, ty=0): super(Sprite, self).__init__() self.frames = sprites[filename] - self.image = self.frames[0][0] + self.image = self.frames[tx][ty] self.rect = self.image.get_rect() - self.rect.move_ip(x * 24 - 4, y * 16 - 18) + self.rect.move_ip(x * 24 - 4, y * 16 - 16) + self.depth = self.rect.midbottom[1] class Overlay(pygame.sprite.Sprite):
--- a/hero.py Sun Aug 21 18:45:26 2011 +0200 +++ b/hero.py Sun Aug 21 19:13:26 2011 +0200 @@ -32,6 +32,7 @@ for step in range(2): yield self.rect.move_ip(dx * 3, dy * 2) + self.depth = self.rect.midbottom[1] + 1 def anim_blocked(self, dx, dy): self.facing = self.faces[dx][dy] @@ -42,6 +43,7 @@ def anim_drop(self): self.rect.move_ip(0, -15) + self.depth = self.rect.midbottom[1] + 1 for step in range(6): yield self.rect.move_ip(0, step)
--- a/level.py Sun Aug 21 18:45:26 2011 +0200 +++ b/level.py Sun Aug 21 19:13:26 2011 +0200 @@ -3,6 +3,7 @@ import display import hero +import thing import generator import pygame @@ -26,9 +27,15 @@ tx, ty = 0, 3 -class StairsTile(Tile): +class DoorTile(Tile): tx, ty = 3, 3 + def render(self, to_display): + super(DoorTile, self).render(to_display) + v = self.y-1 > 0 and self.map[self.y-1][self.x] == 'x' + door = thing.Door(self.x, self.y, vertical=v) + to_display.sprites.add(door.sprite) + class WallTile(Tile): filename = 'wall.png' @@ -65,7 +72,7 @@ class Level(object): key = { '.': Tile, - '+': StairsTile, + '+': DoorTile, ',': CorridorTile, 'x': WallTile, }
--- a/thing.py Sun Aug 21 18:45:26 2011 +0200 +++ b/thing.py Sun Aug 21 19:13:26 2011 +0200 @@ -3,6 +3,12 @@ import display -class Thing(display.Sprite): - def __init__(self, x, y): - super(Door, self).__init__(x, y, 'objects.png') +class Door(object): + def __init__(self, x, y, vertical): + self.x = x + self.y = y + if vertical: + tx = 1 + else: + tx = 0 + self.sprite = display.Sprite(x, y, 'objects.png', tx, 0)
