From cbaec90dd12bc5d9bea63c315ce835c8207e6fa0 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Tue, 22 May 2018 21:15:01 +0700 Subject: Add option to switch to the original music --- brutalmaze/constants.py | 1 + brutalmaze/game.py | 13 ++++++++++--- brutalmaze/settings.ini | 2 ++ brutalmaze/soundfx/noise.ogg | Bin 0 -> 1422997 bytes wiki | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 brutalmaze/soundfx/noise.ogg diff --git a/brutalmaze/constants.py b/brutalmaze/constants.py index e2c8e43..37ed569 100644 --- a/brutalmaze/constants.py +++ b/brutalmaze/constants.py @@ -28,6 +28,7 @@ from pygame.mixer import Sound SETTINGS = pkg_file('brutalmaze', 'settings.ini') ICON = pygame.image.load(pkg_file('brutalmaze', 'icon.png')) MUSIC = pkg_file('brutalmaze', 'soundfx/music.ogg') +NOISE = pkg_file('brutalmaze', 'soundfx/noise.ogg') mixer = pygame.mixer.get_init() if mixer is None: pygame.mixer.init(frequency=44100) diff --git a/brutalmaze/game.py b/brutalmaze/game.py index 74d6225..7240439 100644 --- a/brutalmaze/game.py +++ b/brutalmaze/game.py @@ -37,7 +37,8 @@ from pygame import KEYDOWN, QUIT, VIDEORESIZE from pygame.time import Clock, get_ticks from appdirs import AppDirs -from .constants import SETTINGS, ICON, MUSIC, HERO_SPEED, COLORS, MIDDLE, WALL +from .constants import ( + SETTINGS, ICON, MUSIC, NOISE, HERO_SPEED, COLORS, MIDDLE, WALL) from .maze import Maze from .misc import deg, round2, sign @@ -71,6 +72,7 @@ class ConfigReader: self.max_fps = self.config.getint('Graphics', 'Maximum FPS') self.muted = self.config.getboolean('Sound', 'Muted') self.musicvol = self.config.getfloat('Sound', 'Music volume') + self.space = self.config.getboolean('Sound', 'Space theme') self.server = self.config.getboolean('Server', 'Enable') self.host = self.config.get('Server', 'Host') self.port = self.config.getint('Server', 'Port') @@ -96,7 +98,7 @@ class ConfigReader: def read_args(self, arguments): """Read and parse a ArgumentParser.Namespace.""" - for option in ('size', 'max_fps', 'muted', 'musicvol', + for option in ('size', 'max_fps', 'muted', 'musicvol', 'space', 'server', 'host', 'port', 'timeout', 'headless'): value = getattr(arguments, option) if value is not None: setattr(self, option, value) @@ -111,7 +113,7 @@ class Game: if config.muted or self.headless: pygame.mixer.quit() else: - pygame.mixer.music.load(MUSIC) + pygame.mixer.music.load(NOISE if config.space else MUSIC) pygame.mixer.music.set_volume(config.musicvol) pygame.mixer.music.play(-1) pygame.display.set_icon(ICON) @@ -369,6 +371,11 @@ def main(): parser.add_argument( '--music-volume', type=float, metavar='VOL', dest='musicvol', help='between 0.0 and 1.0 (fallback: {})'.format(config.musicvol)) + parser.add_argument( + '--space-music', action='store_true', default=None, dest='space', + help='use space music background'.format(config.muted)) + parser.add_argument('--default-music', action='store_false', dest='space', + help='use default music background') parser.add_argument( '--server', action='store_true', default=None, help='enable server (fallback: {})'.format(config.server)) diff --git a/brutalmaze/settings.ini b/brutalmaze/settings.ini index aaa6d98..60cd53c 100644 --- a/brutalmaze/settings.ini +++ b/brutalmaze/settings.ini @@ -8,6 +8,8 @@ Maximum FPS: 60 Muted: no # Volume must be between 0.0 and 1.0 Music volume: 1.0 +# Use space music background, which sounds cold and creepy +Space theme: no [Control] # Input values should be either from Mouse1 to Mouse3 or a keyboard key diff --git a/brutalmaze/soundfx/noise.ogg b/brutalmaze/soundfx/noise.ogg new file mode 100644 index 0000000..73e2157 Binary files /dev/null and b/brutalmaze/soundfx/noise.ogg differ diff --git a/wiki b/wiki index 1e2a1ad..cdd2e0c 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 1e2a1adb64d33e14d506dfcd4e9b9513693721bf +Subproject commit cdd2e0ceaa6a97ae96544a110868fcd70bc2bff7 -- cgit 1.4.1