Mercurial > sypikslang
comparison gamelib/main.py @ 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 | 655a6912e0ae |
children | 74ce25ec2073 |
comparison
equal
deleted
inserted
replaced
60:f9d2ba74723d | 61:a253fae32a6f |
---|---|
4 | 4 |
5 Feel free to put all your game code here, or in other modules in this "gamelib" | 5 Feel free to put all your game code here, or in other modules in this "gamelib" |
6 package. | 6 package. |
7 ''' | 7 ''' |
8 import pygame | 8 import pygame |
9 import optparse | |
10 import sys | |
9 | 11 |
10 from gamelib.engine import Engine | 12 from gamelib.engine import Engine |
11 from gamelib.mainmenu import MainMenu | 13 from gamelib.mainmenu import MainMenu |
12 | 14 |
13 from gamelib.constants import SCREEN | 15 from gamelib.constants import SCREEN, FREQ, BITSIZE, CHANNELS, BUFFER |
14 | 16 |
15 | 17 |
16 pygame.init() | 18 def parse_args(args): |
19 parser = optparse.OptionParser() | |
20 | |
21 parser.add_option('--no-sound', action="store_false", default=True, | |
22 dest="sound", help="disable sound") | |
23 | |
24 return parser.parse_args(args) | |
17 | 25 |
18 | 26 |
19 def main(): | 27 def main(): |
28 opts, args = parse_args(sys.argv) | |
29 pygame.display.init() | |
30 pygame.font.init() | |
31 if opts.sound: | |
32 pygame.mixer.init(FREQ, BITSIZE, CHANNELS, BUFFER) | |
20 screen = pygame.display.set_mode(SCREEN) | 33 screen = pygame.display.set_mode(SCREEN) |
21 engine = Engine(screen) | 34 engine = Engine(screen) |
22 window = MainMenu(screen) | 35 window = MainMenu(screen) |
23 engine.run(window) | 36 engine.run(window) |