comparison 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
comparison
equal deleted inserted replaced
207:709f42eaa55e 208:d07506a2e16e
86 item_type = self.item_types[_type] 86 item_type = self.item_types[_type]
87 item = Item((x, y), _type, item_type, self, end_pos=end_pos) 87 item = Item((x, y), _type, item_type, self, end_pos=end_pos)
88 self.items.append(item) 88 self.items.append(item)
89 89
90 90
91 def autocollect(self, player):
92 for item in self.items:
93 if not item.player:
94 item.autocollect(player)
95
96
91 def change_bullets_into_star_items(self): 97 def change_bullets_into_star_items(self):
92 player = self.players[0] #TODO 98 player = self.players[0] #TODO
93 item_type = self.item_types[6] 99 item_type = self.item_types[6]
94 self.items.extend(Item((bullet.x, bullet.y), 6, item_type, self, player=player) for bullet in self.bullets) 100 self.items.extend(Item((bullet.x, bullet.y), 6, item_type, self, player=player) for bullet in self.bullets)
95 self.bullets = [] 101 self.bullets = []
210 self.modify_difficulty(+6) 216 self.modify_difficulty(+6)
211 self.new_particle((px, py), 0, .8, 192) #TODO: find the real size and range. 217 self.new_particle((px, py), 0, .8, 192) #TODO: find the real size and range.
212 #TODO: display a static particle during one frame at 218 #TODO: display a static particle during one frame at
213 # 12 pixels of the player, in the axis of the “collision”. 219 # 12 pixels of the player, in the axis of the “collision”.
214 220
221 #TODO: is it the right place?
222 if py < 128 and player.state.power >= 128: #TODO: check py.
223 self.autocollect(player)
224
215 for item in self.items: 225 for item in self.items:
216 half_size = item.hitbox_half_size 226 half_size = item.hitbox_half_size
217 bx, by = item.x, item.y 227 bx, by = item.x, item.y
218 bx1, bx2 = bx - half_size, bx + half_size 228 bx1, bx2 = bx - half_size, bx + half_size
219 by1, by2 = by - half_size, by + half_size 229 by1, by2 = by - half_size, by + half_size