Mercurial > touhou
comparison pytouhou/game/game.py @ 197:e1bc8c4cbb1a
Do the right action when collecting an item.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 30 Oct 2011 11:29:08 -0700 |
parents | 1e501e3b6645 |
children | 13918723d1bc |
comparison
equal
deleted
inserted
replaced
196:1e501e3b6645 | 197:e1bc8c4cbb1a |
---|---|
65 def drop_bonus(self, x, y, _type, end_pos=None): | 65 def drop_bonus(self, x, y, _type, end_pos=None): |
66 player = self.players[0] #TODO | 66 player = self.players[0] #TODO |
67 if _type > 6: | 67 if _type > 6: |
68 return | 68 return |
69 item_type = self.item_types[_type] | 69 item_type = self.item_types[_type] |
70 item = Item((x, y), item_type, self, end_pos=end_pos) | 70 item = Item((x, y), _type, item_type, self, end_pos=end_pos) |
71 self.items.append(item) | 71 self.items.append(item) |
72 | 72 |
73 | 73 |
74 def change_bullets_into_star_items(self): | 74 def change_bullets_into_star_items(self): |
75 player = self.players[0] #TODO | 75 player = self.players[0] #TODO |
76 item_type = self.item_types[6] | 76 item_type = self.item_types[6] |
77 self.items.extend(Item((bullet.x, bullet.y), item_type, self, player=player) for bullet in self.bullets) | 77 self.items.extend(Item((bullet.x, bullet.y), 6, item_type, self, player=player) for bullet in self.bullets) |
78 self.bullets = [] | 78 self.bullets = [] |
79 | 79 |
80 | 80 |
81 def new_death(self, pos, index): | 81 def new_death(self, pos, index): |
82 anim = {0: 3, 1: 4, 2: 5}[index % 256] # The TB is wanted, if index isn’t in these values the original game crashs. | 82 anim = {0: 3, 1: 4, 2: 5}[index % 256] # The TB is wanted, if index isn’t in these values the original game crashs. |
246 bx1, bx2 = bx - half_size, bx + half_size | 246 bx1, bx2 = bx - half_size, bx + half_size |
247 by1, by2 = by - half_size, by + half_size | 247 by1, by2 = by - half_size, by + half_size |
248 | 248 |
249 if not (bx2 < px1 or bx1 > px2 | 249 if not (bx2 < px1 or bx1 > px2 |
250 or by2 < py1 or by1 > py2): | 250 or by2 < py1 or by1 > py2): |
251 player.collect(item) | 251 item.on_collect(player.state) |
252 | 252 |
253 | 253 |
254 def cleanup(self): | 254 def cleanup(self): |
255 # Filter out non-visible enemies | 255 # Filter out non-visible enemies |
256 for enemy in tuple(self.enemies): | 256 for enemy in tuple(self.enemies): |