Changeset 239

Show
Ignore:
Timestamp:
01/05/07 02:43:51 (5 years ago)
Author:
mg
Message:

More sound effects.

Location:
trunk
Files:
3 added
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/NEWS.txt

    r236 r239  
    88    a better video mode; if not, give a better first impression by avoiding 
    99    sluggishness. 
    10   - Sound effects!  Well, one sound effect. 
     10  - Sound effects! 
    1111 
    1212December 25, 2006: Released version 0.9.3: the Christmas release. 
  • trunk/src/pyspacewar/sounds/README.txt

    r237 r239  
    11These are public domain sounds, downloaded from 
    22http://www.partnersinrhyme.com/pir/PIRsfx.shtml 
     3 
     4Grenade2.wav was produced from Grenade2.pcm with 
     5mplayer Grenade2.au -ao pcm:file=Grenade2.wav 
  • trunk/src/pyspacewar/ui.py

    r238 r239  
    19741974        self.bounce_sound = pygame.mixer.Sound(find('sounds', 
    19751975                                                    'electricshock.wav')) 
     1976        self.hit_sound = pygame.mixer.Sound(find('sounds', 'Grenade2.wav')) 
     1977        self.explode_sound = pygame.mixer.Sound(find('sounds', 'bomb.wav')) 
    19761978 
    19771979    def _init_fonts(self): 
     
    20032005        for ship in self.ships: 
    20042006            ship.bounce_effect = self.bounce_effect_Ship 
     2007            ship.hit_effect = self.hit_effect_Ship 
     2008            ship.explode_effect = self.explode_effect_Ship 
    20052009        self.ai = map(AIController, self.ships) 
    20062010        self.ai_controlled = [False] * len(self.ships) 
     
    22602264        """Play a sound effect when the player's ship bounces off something.""" 
    22612265        player_id = self.ships.index(ship) 
     2266        if not self.ai_controlled[player_id] and not ship.dead: 
     2267            self.bounce_sound.play() 
     2268 
     2269    def hit_effect_Ship(self, ship, missile): 
     2270        """Play a sound effect when the player's ship is hit.""" 
     2271        player_id = self.ships.index(ship) 
    22622272        if not self.ai_controlled[player_id]: 
    2263             self.bounce_sound.play() 
     2273            self.hit_sound.play() 
     2274 
     2275    def explode_effect_Ship(self, ship, killer): 
     2276        """Play a sound effect when the player's ship explodes.""" 
     2277        player_id = self.ships.index(ship) 
     2278        if not self.ai_controlled[player_id]: 
     2279            self.explode_sound.play() 
    22642280 
    22652281    def draw(self): 
  • trunk/src/pyspacewar/world.py

    r237 r239  
    556556        self.dead = False 
    557557        self.spawn_time = 0 # the value of world.time when last respawned 
     558        self.hit_effect = None 
     559        self.explode_effect = None 
    558560 
    559561    def _set_direction(self, direction): 
     
    640642            killed_by = other.launched_by 
    641643            self.velocity += other.velocity * self.missile_recoil 
     644            if self.hit_effect: 
     645                self.hit_effect(self, other) 
    642646        else: 
    643647            self.health -= self.collision_damage 
     
    659663        self.add_debris(time=50, maxdistance=self.size * 0.5, 
    660664                        howmany=self.world.rng.randrange(9, 21)) 
     665        if self.explode_effect: 
     666            self.explode_effect(self, killed_by) 
    661667 
    662668    def respawn(self):