Mercurial > scrounge
changeset 30:61ca1f30fe84
display defeated monster name
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Tue, 23 Aug 2011 00:55:59 +0200 |
| parents | 6563878f6ed1 |
| children | b87d78c94755 |
| files | effect.py main.py monster.py monsters.png |
| diffstat | 4 files changed, 16 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/effect.py Tue Aug 23 00:20:30 2011 +0200 +++ b/effect.py Tue Aug 23 00:55:59 2011 +0200 @@ -21,7 +21,7 @@ return image class CaptionSprite(pygame.sprite.Sprite): - def __init__(self, x, y, text, color, delay): + def __init__(self, x, y, text, color, delay, ttl): super(CaptionSprite, self).__init__() font = pygame.font.Font(None, 18) self.text = text @@ -32,7 +32,7 @@ self.x = x self.y = y self.rect.center = (x * 24 + 12, y * 16 + 8 - 24) - self.ttl = 16 + self.ttl = ttl self.delay = delay def update(self): @@ -48,14 +48,15 @@ self.kill() class Caption(object): - def __init__(self, x, y, text, color=(255, 255, 255)): + def __init__(self, x, y, text, color=(255, 255, 255), ttl=16): self.x = x self.y = y self.text = text self.color = color + self.ttl = ttl def render(self, to_display, delay=0): self.sprite = CaptionSprite(self.x, self.y, self.text, - self.color, delay) + self.color, delay, self.ttl) to_display.effects.add(self.sprite)
--- a/main.py Tue Aug 23 00:20:30 2011 +0200 +++ b/main.py Tue Aug 23 00:55:59 2011 +0200 @@ -51,7 +51,7 @@ m.act(self.level) for m in monsters: for d, effect in enumerate(m.effects): - effect.render(self.display, delay=d * 8) + effect.render(self.display, delay=d * 12) m.effects = []
--- a/monster.py Tue Aug 23 00:20:30 2011 +0200 +++ b/monster.py Tue Aug 23 00:55:59 2011 +0200 @@ -74,6 +74,7 @@ class Monster(thing.Thing): tx = 0 max_hp = 4 + name = "monster" def __init__(self, x, y): self.x, self.y = x, y @@ -94,8 +95,8 @@ self.die() def die(self): - self.effects.append( - effect.Caption(self.x, self.y, 'RIP', (255, 128, 16))) + c = effect.Caption(self.x, self.y, self.name, (192, 192, 192), ttl=8) + self.effects.append(c) self.dead = True self.sprite.animation = self.sprite.anim_die() self.sprite.animation.next() @@ -129,22 +130,26 @@ class Skeleton(Monster): tx = 0 + name = "skeleton" class Zombie(Monster): tx = 1 + name = "zombie" class Jack(Monster): tx = 2 - + name = "jack" class Bat(Monster): tx = 3 + name = "bat" class Ghost(Monster): tx = 4 + name = "ghost" def render(self, *args, **kwargs): super(Ghost, self).render(*args, **kwargs) @@ -154,7 +159,9 @@ class Eye(Monster): tx = 5 + name = "eye" class Jelly(Ghost): tx = 6 + name = "jelly"
