Mercurial > mamba
comparison mamba/__main__.py @ 48:a70ded879f46
Move argument checking into mamba.options.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sun, 11 Sep 2011 15:22:41 +0200 |
parents | 8521c142cd43 |
children | e5f36843f7cd |
comparison
equal
deleted
inserted
replaced
47:3da564107e14 | 48:a70ded879f46 |
---|---|
3 import sys | 3 import sys |
4 import pygame | 4 import pygame |
5 from pygame.locals import SWSURFACE | 5 from pygame.locals import SWSURFACE |
6 | 6 |
7 from mamba.constants import SCREEN | 7 from mamba.constants import SCREEN |
8 from mamba.options import options, parse_args | 8 from mamba.options import options, parse_args, check_args |
9 from mamba.engine import Engine | 9 from mamba.engine import Engine |
10 from mamba.sound import SoundSystem | 10 from mamba.sound import SoundSystem |
11 from mamba.habitats.mainmenu import MainMenu | 11 from mamba.habitats.mainmenu import MainMenu |
12 from mamba.habitats.level import LevelHabitat | 12 from mamba.habitats.level import LevelHabitat |
13 from mamba.habitats.editor import EditorHabitat | 13 from mamba.habitats.editor import EditorHabitat |
14 | 14 |
15 | 15 |
16 def main(): | 16 def main(): |
17 """Launch the currently unnamed mamab game""" | 17 """Launch the currently unnamed mamab game""" |
18 parse_args(sys.argv) | 18 parse_args(sys.argv) |
19 | 19 if not check_args(): |
20 if options.edit: | 20 sys.exit(1) |
21 if options.level is None: | |
22 print 'You must specifiy a level name when using --edit' | |
23 sys.exit(1) | |
24 start = EditorHabitat(options.level) | |
25 elif options.level is not None: | |
26 start = LevelHabitat(options.level) | |
27 else: | |
28 start = MainMenu() | |
29 | 21 |
30 SoundSystem(options.sound) | 22 SoundSystem(options.sound) |
31 pygame.display.init() | 23 pygame.display.init() |
32 pygame.font.init() | 24 pygame.font.init() |
33 pygame.display.set_mode(SCREEN, SWSURFACE) | 25 pygame.display.set_mode(SCREEN, SWSURFACE) |
34 pygame.display.set_caption('Mamba') | 26 pygame.display.set_caption('Mamba') |
35 | 27 |
28 if options.edit: | |
29 start = EditorHabitat(options.level) | |
30 elif options.level is not None: | |
31 start = LevelHabitat(options.level) | |
32 else: | |
33 start = MainMenu() | |
34 | |
36 engine = Engine() | 35 engine = Engine() |
37 engine.set_habitat(start) | 36 engine.set_habitat(start) |
38 engine.run() | 37 engine.run() |