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

Add a sound_in_vacuum option. It defaults to True, which is a bit unrealistic,
but makes the gameplay more fun.

Change options menu titles.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/pyspacewar/ui.py

    r250 r253  
    14471447        """Initialize the mode.""" 
    14481448        self.menu_items = [ 
    1449             ('Screen size: %dx%d' % self.ui.fullscreen_mode, 
     1449            ('Screen size\t%dx%d' % self.ui.fullscreen_mode, 
    14501450             self.ui.screen_resolution_menu), 
    1451             (self.ui.fullscreen and 'Windowed mode' 
    1452                                  or 'Full screen mode', 
     1451            (self.ui.fullscreen and 'Full screen mode\ton' 
     1452                                 or 'Full screen mode\toff', 
    14531453             self.toggle_fullscreen), 
    1454             (self.ui.show_missile_trails and 'Hide missile orbits' 
    1455                                           or 'Show missile orbits', 
     1454            (self.ui.show_missile_trails and 'Missile orbits\ton' 
     1455                                          or 'Missile orbits\toff', 
    14561456             self.toggle_missile_orbits), 
     1457            (self.ui.sound_in_vacuum and 'Sound in vacuum\ton' 
     1458                                      or 'Sound in vacuum\toff', 
     1459             self.toggle_sound_in_vacuum), 
    14571460            ('Controls', self.ui.controls_menu), 
    14581461            ('Return to main menu', self.close_menu), 
     
    14811484        """Toggle missile orbits and reflect the setting in the menu.""" 
    14821485        self.ui.toggle_missile_orbits() 
     1486        self.reinit_menu() 
     1487 
     1488    def toggle_sound_in_vacuum(self): 
     1489        """Toggle sound in vacuum and reflect the setting in the menu.""" 
     1490        self.ui.toggle_sound_in_vacuum() 
    14831491        self.reinit_menu() 
    14841492 
     
    17841792    fullscreen_mode = None          # Desired video mode (w, h) 
    17851793    show_missile_trails = True      # Show missile trails by default 
     1794    sound_in_vacuum = True          # Can you hear what happens to AI ships? 
    17861795    show_debug_info = False         # Hide debug info by default 
    17871796    desired_zoom_level = 1.0        # The desired zoom level 
     
    18331842        self.show_missile_trails = config.getboolean('video', 
    18341843                                                     'show_missile_trails') 
     1844        self.sound_in_vacuum = config.getboolean('sound', 
     1845                                                 'sound_in_vacuum') 
    18351846        for action in self.controls: 
    18361847            key = config.get('controls', action) 
     
    18631874        config.set('video', 'show_missile_trails', 
    18641875                   str(self.show_missile_trails)) 
     1876        config.add_section('sound') 
     1877        config.set('sound', 'sound_in_vacuum', str(self.sound_in_vacuum)) 
    18651878        config.add_section('controls') 
    18661879        for action, keys in self.controls.items(): 
     
    22962309        self.show_missile_trails = not self.show_missile_trails 
    22972310 
     2311    def toggle_sound_in_vacuum(self): 
     2312        """Toggle sound in vacuum.""" 
     2313        self.sound_in_vacuum = not self.sound_in_vacuum 
     2314 
    22982315    def toggle_ai(self, player_id): 
    22992316        """Toggle AI control for player.""" 
     
    23372354        """Play a sound effect when the player's ship bounces off something.""" 
    23382355        player_id = self.ships.index(ship) 
    2339         if not self.ai_controlled[player_id]: 
     2356        if not self.ai_controlled[player_id] or self.sound_in_vacuum: 
    23402357            self.fire_sound.play() 
    23412358 
     
    23432360        """Play a sound effect when the player's ship bounces off something.""" 
    23442361        player_id = self.ships.index(ship) 
    2345         if not self.ai_controlled[player_id] and not ship.dead: 
    2346             self.bounce_sound.play() 
     2362        if not ship.dead: 
     2363            # It sounds weird to hear that sound when dead ships bounce 
     2364            if not self.ai_controlled[player_id] or self.sound_in_vacuum: 
     2365                self.bounce_sound.play() 
    23472366 
    23482367    def hit_effect_Ship(self, ship, missile): 
    23492368        """Play a sound effect when the player's ship is hit.""" 
    23502369        player_id = self.ships.index(ship) 
    2351         if not self.ai_controlled[player_id]: 
     2370        if not self.ai_controlled[player_id] or self.sound_in_vacuum: 
    23522371            self.hit_sound.play() 
    23532372 
     
    23552374        """Play a sound effect when the player's ship explodes.""" 
    23562375        player_id = self.ships.index(ship) 
    2357         if not self.ai_controlled[player_id]: 
     2376        if not self.ai_controlled[player_id] or self.sound_in_vacuum: 
    23582377            self.explode_sound.play() 
    23592378 
     
    23672386        makes_noise = False 
    23682387        for player_id, ship in enumerate(self.ships): 
    2369             if not self.ai_controlled[player_id]: 
     2388            if not self.ai_controlled[player_id] or self.sound_in_vacuum: 
    23702389                makes_noise = (ship.forward_thrust or ship.rear_thrust or 
    23712390                               ship.left_thrust or ship.right_thrust or