Mercurial > sypikslang
changeset 61:a253fae32a6f
Add no-sound option (slow shutdown bug workaround)
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Tue, 08 May 2012 16:27:44 +0200 |
parents | f9d2ba74723d |
children | 38f41d046c6f |
files | gamelib/constants.py gamelib/main.py |
diffstat | 2 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/constants.py Mon May 07 23:41:00 2012 +0200 +++ b/gamelib/constants.py Tue May 08 16:27:44 2012 +0200 @@ -4,3 +4,9 @@ HEIGHT = 600 SCREEN = (WIDTH, HEIGHT) FPS = 30 + +# Sound related (standard options) +FREQ = 44100 +BITSIZE = -16 # unsigned 16 bit +CHANNELS = 2 +BUFFER = 1024
--- a/gamelib/main.py Mon May 07 23:41:00 2012 +0200 +++ b/gamelib/main.py Tue May 08 16:27:44 2012 +0200 @@ -6,17 +6,30 @@ package. ''' import pygame +import optparse +import sys from gamelib.engine import Engine from gamelib.mainmenu import MainMenu -from gamelib.constants import SCREEN +from gamelib.constants import SCREEN, FREQ, BITSIZE, CHANNELS, BUFFER -pygame.init() +def parse_args(args): + parser = optparse.OptionParser() + + parser.add_option('--no-sound', action="store_false", default=True, + dest="sound", help="disable sound") + + return parser.parse_args(args) def main(): + opts, args = parse_args(sys.argv) + pygame.display.init() + pygame.font.init() + if opts.sound: + pygame.mixer.init(FREQ, BITSIZE, CHANNELS, BUFFER) screen = pygame.display.set_mode(SCREEN) engine = Engine(screen) window = MainMenu(screen)