diff pytouhou/game/enemy.py @ 152:86807b8a63bd

Add collisions with enemies and items.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 09 Oct 2011 15:32:43 -0700
parents 5cf927cbd9c5
children 364935f6e313
line wrap: on
line diff
--- a/pytouhou/game/enemy.py
+++ b/pytouhou/game/enemy.py
@@ -67,6 +67,7 @@ class Enemy(object):
         self.acceleration = 0.
 
         self.hitbox = (0, 0)
+        self.hitbox_half_size = (0, 0)
         self.screen_box = None
 
         self.pop_enemy = pop_enemy
@@ -144,6 +145,14 @@ class Enemy(object):
         self._anmrunner.run_frame()
 
 
+    def collide(self, player):
+        if self.touchable:
+            #TODO: animation
+            #TODO: doesn’t always kill herself (a boss for example), search how
+            self._removed = True
+            player.die()
+
+
     def set_pos(self, x, y, z):
         self.x, self.y = x, y
         self.interpolator = Interpolator((x, y))