Changeset 237

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

Another sound effect: bouncing off something.

Add sound effects to the set of distributed files in setup.py

Location:
trunk
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/setup.py

    r204 r237  
    5050      packages=['pyspacewar'], 
    5151      package_dir={'pyspacewar': 'src/pyspacewar'}, 
    52       package_data={'pyspacewar': ['images/*']}, 
     52      package_data={'pyspacewar': ['images/*', 'sounds/*']}, 
    5353     ) 
  • trunk/src/pyspacewar/sounds/README.txt

    r236 r237  
    11These are public domain sounds, downloaded from 
    2 http://www.partnersinrhyme.com/soundfx/warsounds.shtml 
     2http://www.partnersinrhyme.com/pir/PIRsfx.shtml 
  • trunk/src/pyspacewar/ui.py

    r236 r237  
    19721972        self.fire_sound = pygame.mixer.Sound(find('sounds', 
    19731973                                                  'Gun_Silencer.wav')) 
     1974        self.bounce_sound = pygame.mixer.Sound(find('sounds', 
     1975                                                    'electricshock.wav')) 
    19741976 
    19751977    def _init_fonts(self): 
     
    19992001                             rng=self.rng) 
    20002002        self.ships = self.game.ships 
     2003        for ship in self.ships: 
     2004            ship.bounce_effect = self.bounce_effect_Ship 
    20012005        self.ai = map(AIController, self.ships) 
    20022006        self.ai_controlled = [False] * len(self.ships) 
     
    22532257            self.fire_sound.play() 
    22542258 
     2259    def bounce_effect_Ship(self, ship, obstacle): 
     2260        """Play a sound effect when the player's ship bounces off something.""" 
     2261        player_id = self.ships.index(ship) 
     2262        if not self.ai_controlled[player_id]: 
     2263            self.bounce_sound.play() 
     2264 
    22552265    def draw(self): 
    22562266        """Draw the state of the game""" 
     
    24452455            self.update_missile_trails() 
    24462456            self.framedrop_needed = not self.game.wait_for_tick() 
    2447  
  • trunk/src/pyspacewar/world.py

    r231 r237  
    346346        self.appearance = appearance 
    347347        self.world = None 
     348        self.bounce_effect = None 
    348349 
    349350    def distanceTo(self, other): 
     
    463464        collision_distance = other.radius + self.radius 
    464465        self.position = other.position + normal.scaled(collision_distance) 
     466        if self.bounce_effect: 
     467            self.bounce_effect(self, other) 
    465468 
    466469    def add_debris(self, howmany=None, maxdistance=1.0, time=5.0):