comparison pytouhou/game/enemy.py @ 328:56523a16db1d

Fix some replay synchronization issues and update the TODO.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 21 Jun 2012 19:59:41 +0200
parents 1a4ffdda8735
children 1bb78c469f64
comparison
equal deleted inserted replaced
327:13201d90bb22 328:56523a16db1d
208 anim = {0: 3, 1: 4, 2: 5}[self.death_anim % 256] # The TB is wanted, if index isn’t in these values the original game crashs. 208 anim = {0: 3, 1: 4, 2: 5}[self.death_anim % 256] # The TB is wanted, if index isn’t in these values the original game crashs.
209 self._game.new_effect((self.x, self.y), anim) 209 self._game.new_effect((self.x, self.y), anim)
210 210
211 211
212 def drop_particles(self, number, color): 212 def drop_particles(self, number, color):
213 #TODO: white particles are only used in stage 3 to 6,
214 # in other stages they are blue.
215 if color == 0: 213 if color == 0:
216 if self._game.stage in [1, 2, 7]: 214 if self._game.stage in [1, 2, 7]:
217 color = 3 215 color = 3
218 for i in range(number): 216 for i in range(number):
219 self._game.new_particle((self.x, self.y), color, 4., 256) #TODO: find the real size. 217 self._game.new_particle((self.x, self.y), color, 3., 256) #TODO: find the real size.
220 218
221 219
222 def set_aux_anm(self, number, script): 220 def set_aux_anm(self, number, script):
223 self.aux_anm[number] = Effect((self.x, self.y), script, self._anm_wrapper) 221 self.aux_anm[number] = Effect((self.x, self.y), script, self._anm_wrapper)
224 222
289 if not (bx2 < ex1 or bx1 > ex2 287 if not (bx2 < ex1 or bx1 > ex2
290 or by2 < ey1 or by1 > ey2): 288 or by2 < ey1 or by1 > ey2):
291 bullet.collide() 289 bullet.collide()
292 if self.damageable: 290 if self.damageable:
293 damages += bullet.damage 291 damages += bullet.damage
294 self.drop_particles(1, 1)
295 292
296 # Check for enemy-laser collisions 293 # Check for enemy-laser collisions
297 for laser in self._game.players_lasers: 294 for laser in self._game.players_lasers:
298 if not laser: 295 if not laser:
299 continue 296 continue
304 301
305 if not (lx2 < ex1 or lx1 > ex2 302 if not (lx2 < ex1 or lx1 > ex2
306 or ly < ey1): 303 or ly < ey1):
307 if self.damageable: 304 if self.damageable:
308 damages += laser.damage 305 damages += laser.damage
309 self.drop_particles(1, 1) 306 self.drop_particles(1, 1) #TODO: don’t call each frame.
310 307
311 # Check for enemy-player collisions 308 # Check for enemy-player collisions
312 ex1, ex2 = ex - ehalf_size_x * 2. / 3., ex + ehalf_size_x * 2. / 3. 309 ex1, ex2 = ex - ehalf_size_x * 2. / 3., ex + ehalf_size_x * 2. / 3.
313 ey1, ey2 = ey - ehalf_size_y * 2. / 3., ey + ehalf_size_y * 2. / 3. 310 ey1, ey2 = ey - ehalf_size_y * 2. / 3., ey + ehalf_size_y * 2. / 3.
314 if self.collidable: 311 if self.collidable:
405 402
406 403
407 def update(self): 404 def update(self):
408 if self.process: 405 if self.process:
409 self.process.run_iteration() 406 self.process.run_iteration()
410 self.handle_callbacks()
411 407
412 x, y = self.x, self.y 408 x, y = self.x, self.y
413 409
414 if self.update_mode == 1: 410 if self.update_mode == 1:
415 speed = 0.0 411 speed = 0.0
479 for anm in self.aux_anm: 475 for anm in self.aux_anm:
480 if anm: 476 if anm:
481 anm.x, anm.y = self.x, self.y 477 anm.x, anm.y = self.x, self.y
482 anm.update() 478 anm.update()
483 479
480 self.handle_callbacks()
481
484 self.frame += 1 482 self.frame += 1
485 483