Mercurial > touhou
comparison pytouhou/game/game.py @ 123:d1c82d43bbf3
Various optimizations
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sat, 10 Sep 2011 11:58:24 +0200 |
parents | 174324a4da51 |
children | 11ab06f4c4c6 |
comparison
equal
deleted
inserted
replaced
122:174324a4da51 | 123:d1c82d43bbf3 |
---|---|
63 def run_iter(self, keystate): | 63 def run_iter(self, keystate): |
64 # 1. VMs. | 64 # 1. VMs. |
65 self.ecl_runner.run_iter() | 65 self.ecl_runner.run_iter() |
66 | 66 |
67 # 2. Filter out destroyed enemies | 67 # 2. Filter out destroyed enemies |
68 self.enemies[:] = (enemy for enemy in self.enemies if not enemy._removed) | 68 self.enemies = [enemy for enemy in self.enemies if not enemy._removed] |
69 | 69 |
70 # 3. Let's play! | 70 # 3. Let's play! |
71 for enemy in self.enemies: | 71 for enemy in self.enemies: |
72 enemy.update() | 72 enemy.update() |
73 | 73 |
90 enemy._removed = True | 90 enemy._removed = True |
91 self.enemies.remove(enemy) | 91 self.enemies.remove(enemy) |
92 | 92 |
93 # Filter out-of-scren bullets | 93 # Filter out-of-scren bullets |
94 # TODO: was_visible thing | 94 # TODO: was_visible thing |
95 bullets = self.game_state.bullets | 95 self.game_state.bullets = [bullet for bullet in self.game_state.bullets if bullet.is_visible(384, 448)] |
96 for bullet in tuple(bullets): | |
97 if not bullet.is_visible(384, 448): | |
98 bullets.remove(bullet) | |
99 | 96 |
100 # Disable boss mode if it is dead/it has timeout | 97 # Disable boss mode if it is dead/it has timeout |
101 if self.game_state.boss and self.game_state.boss._removed: | 98 if self.game_state.boss and self.game_state.boss._removed: |
102 self.game_state.boss = None | 99 self.game_state.boss = None |
103 | 100 |