comparison pytouhou/game/game.py @ 304:f3099ebf4f61

Update attribute names to reflect the actual interface.
author Thibaut Girka <thib@sitedethib.com>
date Tue, 13 Mar 2012 18:38:14 +0100
parents 647bde10353d
children 5492472963b0
comparison
equal deleted inserted replaced
303:647bde10353d 304:f3099ebf4f61
104 self.difficulty = self.difficulty_max 104 self.difficulty = self.difficulty_max
105 105
106 106
107 def enable_effect(self): 107 def enable_effect(self):
108 self.effect = Effect((-32., -16.), 0, self.effect_anm_wrapper) #TODO: find why this offset is necessary. 108 self.effect = Effect((-32., -16.), 0, self.effect_anm_wrapper) #TODO: find why this offset is necessary.
109 self.effect._sprite.allow_dest_offset = True #TODO: should be the role of anm’s 25th instruction. Investigate! 109 self.effect.sprite.allow_dest_offset = True #TODO: should be the role of anm’s 25th instruction. Investigate!
110 110
111 111
112 def disable_effect(self): 112 def disable_effect(self):
113 self.effect = None 113 self.effect = None
114 114
166 self.ecl_runner.run_iter() 166 self.ecl_runner.run_iter()
167 if self.frame % (32*60) == (32*60): #TODO: check if that is really that frame. 167 if self.frame % (32*60) == (32*60): #TODO: check if that is really that frame.
168 self.modify_difficulty(+100) 168 self.modify_difficulty(+100)
169 169
170 # 2. Filter out destroyed enemies 170 # 2. Filter out destroyed enemies
171 self.enemies = [enemy for enemy in self.enemies if not enemy._removed] 171 self.enemies = [enemy for enemy in self.enemies if not enemy.removed]
172 self.effects = [effect for effect in self.effects if not effect._removed] 172 self.effects = [effect for effect in self.effects if not effect.removed]
173 self.bullets = [bullet for bullet in self.bullets if not bullet._removed] 173 self.bullets = [bullet for bullet in self.bullets if not bullet.removed]
174 self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets if not bullet._removed] 174 self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets if not bullet.removed]
175 self.items = [item for item in self.items if not item._removed] 175 self.items = [item for item in self.items if not item.removed]
176 176
177 177
178 # 3. Let's play! 178 # 3. Let's play!
179 # In the original game, updates are done in prioritized functions called "chains" 179 # In the original game, updates are done in prioritized functions called "chains"
180 # We have to mimic this functionnality to be replay-compatible with the official game. 180 # We have to mimic this functionnality to be replay-compatible with the official game.
325 325
326 def cleanup(self): 326 def cleanup(self):
327 # Filter out non-visible enemies 327 # Filter out non-visible enemies
328 for enemy in self.enemies: 328 for enemy in self.enemies:
329 if enemy.is_visible(self.width, self.height): 329 if enemy.is_visible(self.width, self.height):
330 enemy._was_visible = True 330 enemy.was_visible = True
331 elif enemy._was_visible: 331 elif enemy.was_visible:
332 # Filter out-of-screen enemy 332 # Filter out-of-screen enemy
333 enemy._removed = True 333 enemy.removed = True
334 334
335 self.enemies = [enemy for enemy in self.enemies if not enemy._removed] 335 self.enemies = [enemy for enemy in self.enemies if not enemy.removed]
336 336
337 # Filter out-of-scren bullets 337 # Filter out-of-scren bullets
338 self.bullets = [bullet for bullet in self.bullets 338 self.bullets = [bullet for bullet in self.bullets
339 if not bullet._removed] 339 if not bullet.removed]
340 self.players_bullets = [bullet for bullet in self.players_bullets 340 self.players_bullets = [bullet for bullet in self.players_bullets
341 if not bullet._removed] 341 if not bullet.removed]
342 for i, laser in enumerate(self.players_lasers): 342 for i, laser in enumerate(self.players_lasers):
343 if laser and laser._removed: 343 if laser and laser.removed:
344 self.players_lasers[i] = None 344 self.players_lasers[i] = None
345 self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets 345 self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets
346 if not bullet._removed] 346 if not bullet.removed]
347 self.effects = [effect for effect in self.effects if not effect._removed] 347 self.effects = [effect for effect in self.effects if not effect.removed]
348 348
349 # Filter “timed-out” lasers 349 # Filter “timed-out” lasers
350 self.lasers = [laser for laser in self.lasers if not laser._removed] 350 self.lasers = [laser for laser in self.lasers if not laser.removed]
351 351
352 # Filter out-of-scren items 352 # Filter out-of-scren items
353 items = [] 353 items = []
354 for item in self.items: 354 for item in self.items:
355 if item.y < self.height: 355 if item.y < self.height:
357 else: 357 else:
358 self.modify_difficulty(-3) 358 self.modify_difficulty(-3)
359 self.items = items 359 self.items = items
360 360
361 # Disable boss mode if it is dead/it has timeout 361 # Disable boss mode if it is dead/it has timeout
362 if self.boss and self.boss._enemy._removed: 362 if self.boss and self.boss._enemy.removed:
363 self.boss = None 363 self.boss = None
364 364