diff pytouhou/game/game.py @ 165:c8c60291c56f

Implement item dropping by enemies.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 18 Oct 2011 07:35:02 -0700
parents 5271789c067d
children dcf32488a2c9
line wrap: on
line diff
--- a/pytouhou/game/game.py
+++ b/pytouhou/game/game.py
@@ -55,6 +55,8 @@ class Game(object):
 
     def drop_bonus(self, x, y, _type):
         player = self.players[0] #TODO
+        if _type > 6:
+            return
         item_type = self.item_types[_type]
         item = Item((x, y), item_type, self)
         self.items.append(item)
@@ -190,6 +192,9 @@ class Game(object):
         self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets if bullet.is_visible(384, 448)]
         self.players_bullets = [bullet for bullet in self.players_bullets if bullet.is_visible(384, 448)]
 
+        # Filter out-of-scren items
+        self.items = [item for item in self.items if item.y < 448]
+
         # Disable boss mode if it is dead/it has timeout
         if self.boss and self.boss._removed:
             self.boss = None