Mercurial > mamba
annotate 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 |
rev | line source |
---|---|
3
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
1 """Main module for the game""" |
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
2 |
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
3 import sys |
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
4 import pygame |
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
5 from pygame.locals import SWSURFACE |
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
6 |
39 | 7 from mamba.constants import SCREEN |
48
a70ded879f46
Move argument checking into mamba.options.
Simon Cross <hodgestar@gmail.com>
parents:
42
diff
changeset
|
8 from mamba.options import options, parse_args, check_args |
12 | 9 from mamba.engine import Engine |
30 | 10 from mamba.sound import SoundSystem |
15
ad2bcbf492bf
Hook up top-level habitat support.
Simon Cross <hodgestar@gmail.com>
parents:
12
diff
changeset
|
11 from mamba.habitats.mainmenu import MainMenu |
22
a396e34476ca
Put LevelHabitat into __main__.
Simon Cross <hodgestar@gmail.com>
parents:
17
diff
changeset
|
12 from mamba.habitats.level import LevelHabitat |
42
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
39
diff
changeset
|
13 from mamba.habitats.editor import EditorHabitat |
3
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
14 |
17
236de980209a
Add simple command line processing
Neil Muller <drnlmuller@gmail.com>
parents:
15
diff
changeset
|
15 |
0 | 16 def main(): |
3
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
17 """Launch the currently unnamed mamab game""" |
39 | 18 parse_args(sys.argv) |
48
a70ded879f46
Move argument checking into mamba.options.
Simon Cross <hodgestar@gmail.com>
parents:
42
diff
changeset
|
19 if not check_args(): |
a70ded879f46
Move argument checking into mamba.options.
Simon Cross <hodgestar@gmail.com>
parents:
42
diff
changeset
|
20 sys.exit(1) |
42
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
39
diff
changeset
|
21 |
39 | 22 SoundSystem(options.sound) |
3
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
23 pygame.display.init() |
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
24 pygame.font.init() |
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
25 pygame.display.set_mode(SCREEN, SWSURFACE) |
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
26 pygame.display.set_caption('Mamba') |
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
27 |
48
a70ded879f46
Move argument checking into mamba.options.
Simon Cross <hodgestar@gmail.com>
parents:
42
diff
changeset
|
28 if options.edit: |
a70ded879f46
Move argument checking into mamba.options.
Simon Cross <hodgestar@gmail.com>
parents:
42
diff
changeset
|
29 start = EditorHabitat(options.level) |
a70ded879f46
Move argument checking into mamba.options.
Simon Cross <hodgestar@gmail.com>
parents:
42
diff
changeset
|
30 elif options.level is not None: |
a70ded879f46
Move argument checking into mamba.options.
Simon Cross <hodgestar@gmail.com>
parents:
42
diff
changeset
|
31 start = LevelHabitat(options.level) |
a70ded879f46
Move argument checking into mamba.options.
Simon Cross <hodgestar@gmail.com>
parents:
42
diff
changeset
|
32 else: |
a70ded879f46
Move argument checking into mamba.options.
Simon Cross <hodgestar@gmail.com>
parents:
42
diff
changeset
|
33 start = MainMenu() |
a70ded879f46
Move argument checking into mamba.options.
Simon Cross <hodgestar@gmail.com>
parents:
42
diff
changeset
|
34 |
12 | 35 engine = Engine() |
17
236de980209a
Add simple command line processing
Neil Muller <drnlmuller@gmail.com>
parents:
15
diff
changeset
|
36 engine.set_habitat(start) |
12 | 37 engine.run() |