Mercurial > touhou
comparison pytouhou/game/game.py @ 258:620134bc51f4
Move bullet visibility check to Bullet to improve performance and prepare handling of flags 1024 and 2048.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sun, 22 Jan 2012 22:03:57 +0100 |
parents | a0d6b1915591 |
children | 3631abb6e95b |
comparison
equal
deleted
inserted
replaced
257:9b699e8de4a7 | 258:620134bc51f4 |
---|---|
264 enemy._removed = True | 264 enemy._removed = True |
265 | 265 |
266 self.enemies = [enemy for enemy in self.enemies if not enemy._removed] | 266 self.enemies = [enemy for enemy in self.enemies if not enemy._removed] |
267 | 267 |
268 # Filter out-of-scren bullets | 268 # Filter out-of-scren bullets |
269 # TODO: move to Bullet? | |
270 for bullet in chain(self.bullets, self.players_bullets): | |
271 if bullet.flags & 448: | |
272 bullet._was_visible = False | |
273 elif bullet.is_visible(self.width, self.height): | |
274 bullet._was_visible = True | |
275 elif bullet._was_visible: | |
276 # Filter out-of-screen bullets | |
277 bullet._removed = True | |
278 | |
279 self.bullets = [bullet for bullet in self.bullets | 269 self.bullets = [bullet for bullet in self.bullets |
280 if not bullet._removed] | 270 if not bullet._removed] |
281 self.players_bullets = [bullet for bullet in self.players_bullets | 271 self.players_bullets = [bullet for bullet in self.players_bullets |
282 if not bullet._removed] | 272 if not bullet._removed] |
283 self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets | 273 self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets |