diff pytouhou/game/game.py @ 208:d07506a2e16e

Implement autocollection of items.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 08 Nov 2011 22:10:44 -0800
parents df8b2ab54639
children 577f45454402
line wrap: on
line diff
--- a/pytouhou/game/game.py
+++ b/pytouhou/game/game.py
@@ -88,6 +88,12 @@ class Game(object):
         self.items.append(item)
 
 
+    def autocollect(self, player):
+        for item in self.items:
+            if not item.player:
+                item.autocollect(player)
+
+
     def change_bullets_into_star_items(self):
         player = self.players[0] #TODO
         item_type = self.item_types[6]
@@ -212,6 +218,10 @@ class Game(object):
                     #TODO: display a static particle during one frame at
                     # 12 pixels of the player, in the axis of the “collision”.
 
+            #TODO: is it the right place?
+            if py < 128 and player.state.power >= 128: #TODO: check py.
+                self.autocollect(player)
+
             for item in self.items:
                 half_size = item.hitbox_half_size
                 bx, by = item.x, item.y