changeset 19:46e13b7784aa

monsters and some things can block
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sun, 21 Aug 2011 23:05:33 +0200
parents 4356dae3b3da
children 43b2c4637eee
files monster.py
diffstat 1 files changed, 55 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/monster.py	Sun Aug 21 23:05:33 2011 +0200
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import thing
+import display
+
+class MonsterSprite(display.Sprite):
+    def __init__(self, x, y, tx):
+        self.tx = tx
+        self.ty = 0
+        super(MonsterSprite, self).__init__(x, y, 'monsters.png')
+        self.animation = self.anim_default()
+
+    def update(self):
+        try:
+            self.animation.next()
+        except StopIteration:
+            self.animation = self.anim_default()
+            self.animation.next()
+
+    def anim_default(self):
+        self.depth = self.rect.midbottom[1] + 1
+        for frame in range(4):
+            self.image = self.frames[self.tx][frame % 4]
+            yield
+            yield
+            yield
+
+
+class Monster(thing.Thing):
+    tx = 0
+
+    def __init__(self, x, y):
+        self.x, self.y = x, y
+
+    def render(self, to_display):
+        self.sprite = MonsterSprite(self.x, self.y, self.tx)
+        to_display.sprites.add(self.sprite)
+        to_display.sprites.add(thing.ShadowSprite(self.sprite))
+
+
+class Skeleton(Monster):
+    tx = 0
+
+
+class Zombie(Monster):
+    tx = 1
+
+
+class Jack(Monster):
+    tx = 2
+
+
+class Bat(Monster):
+    tx = 3