Mercurial > touhou
comparison pytouhou/game/enemy.py @ 379:e0e284fcb288
Make a sound when an enemy is hit.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 30 Aug 2012 11:34:56 +0200 |
parents | 7dc012f631dc |
children | 690b5faaa0e6 |
comparison
equal
deleted
inserted
replaced
378:11d895b6c0dc | 379:e0e284fcb288 |
---|---|
104 24: 'tan02', #XXX | 104 24: 'tan02', #XXX |
105 25: 'kira00', | 105 25: 'kira00', |
106 26: 'kira01', | 106 26: 'kira01', |
107 27: 'kira02' | 107 27: 'kira02' |
108 }[index] | 108 }[index] |
109 self._game.enemy_sfx.play('%s.wav' % name) | 109 self._game.sfx_player.play('%s.wav' % name) |
110 | 110 |
111 | 111 |
112 def set_bullet_attributes(self, type_, anim, sprite_idx_offset, | 112 def set_bullet_attributes(self, type_, anim, sprite_idx_offset, |
113 bullets_per_shot, number_of_shots, speed, speed2, | 113 bullets_per_shot, number_of_shots, speed, speed2, |
114 launch_angle, angle, flags): | 114 launch_angle, angle, flags): |
226 | 226 |
227 | 227 |
228 def die_anim(self): | 228 def die_anim(self): |
229 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. | 229 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. |
230 self._game.new_effect((self.x, self.y), anim) | 230 self._game.new_effect((self.x, self.y), anim) |
231 self._game.sfx_player.play('enep00.wav') | |
231 | 232 |
232 | 233 |
233 def drop_particles(self, number, color): | 234 def drop_particles(self, number, color): |
234 if color == 0: | 235 if color == 0: |
235 if self._game.stage in [1, 2, 7]: | 236 if self._game.stage in [1, 2, 7]: |
310 if not (bx2 < ex1 or bx1 > ex2 | 311 if not (bx2 < ex1 or bx1 > ex2 |
311 or by2 < ey1 or by1 > ey2): | 312 or by2 < ey1 or by1 > ey2): |
312 bullet.collide() | 313 bullet.collide() |
313 if self.damageable: | 314 if self.damageable: |
314 damages += bullet.damage | 315 damages += bullet.damage |
316 self._game.sfx_player.play('damage00.wav') | |
315 | 317 |
316 # Check for enemy-laser collisions | 318 # Check for enemy-laser collisions |
317 for laser in self._game.players_lasers: | 319 for laser in self._game.players_lasers: |
318 if not laser: | 320 if not laser: |
319 continue | 321 continue |
324 | 326 |
325 if not (lx2 < ex1 or lx1 > ex2 | 327 if not (lx2 < ex1 or lx1 > ex2 |
326 or ly < ey1): | 328 or ly < ey1): |
327 if self.damageable: | 329 if self.damageable: |
328 damages += laser.damage | 330 damages += laser.damage |
331 self._game.sfx_player.play('damage00.wav') | |
329 self.drop_particles(1, 1) #TODO: don’t call each frame. | 332 self.drop_particles(1, 1) #TODO: don’t call each frame. |
330 | 333 |
331 # Check for enemy-player collisions | 334 # Check for enemy-player collisions |
332 ex1, ex2 = ex - ehalf_size_x * 2. / 3., ex + ehalf_size_x * 2. / 3. | 335 ex1, ex2 = ex - ehalf_size_x * 2. / 3., ex + ehalf_size_x * 2. / 3. |
333 ey1, ey2 = ey - ehalf_size_y * 2. / 3., ey + ehalf_size_y * 2. / 3. | 336 ey1, ey2 = ey - ehalf_size_y * 2. / 3., ey + ehalf_size_y * 2. / 3. |