Mercurial > mamba
annotate mamba/__main__.py @ 39:3ab5097e8757
Refactor options.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sun, 11 Sep 2011 15:03:56 +0200 |
parents | cccf1675731c |
children | 8521c142cd43 |
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 |
8 from mamba.options import options, parse_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 |
3
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
13 |
17
236de980209a
Add simple command line processing
Neil Muller <drnlmuller@gmail.com>
parents:
15
diff
changeset
|
14 |
0 | 15 def main(): |
3
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
16 """Launch the currently unnamed mamab game""" |
39 | 17 parse_args(sys.argv) |
18 SoundSystem(options.sound) | |
3
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
19 pygame.display.init() |
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
20 pygame.font.init() |
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
21 pygame.display.set_mode(SCREEN, SWSURFACE) |
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
22 pygame.display.set_caption('Mamba') |
6b9fa5e2fbc6
Add initial window that does very little
Neil Muller <drnlmuller@gmail.com>
parents:
0
diff
changeset
|
23 |
12 | 24 engine = Engine() |
39 | 25 if options.level is None: |
26 if options.edit: | |
17
236de980209a
Add simple command line processing
Neil Muller <drnlmuller@gmail.com>
parents:
15
diff
changeset
|
27 print 'You must specifiy a level name when using --edit' |
236de980209a
Add simple command line processing
Neil Muller <drnlmuller@gmail.com>
parents:
15
diff
changeset
|
28 sys.exit(1) |
236de980209a
Add simple command line processing
Neil Muller <drnlmuller@gmail.com>
parents:
15
diff
changeset
|
29 start = MainMenu() |
236de980209a
Add simple command line processing
Neil Muller <drnlmuller@gmail.com>
parents:
15
diff
changeset
|
30 else: |
39 | 31 start = LevelHabitat(options.level) |
17
236de980209a
Add simple command line processing
Neil Muller <drnlmuller@gmail.com>
parents:
15
diff
changeset
|
32 # TODO: Hook up firing up editor |
236de980209a
Add simple command line processing
Neil Muller <drnlmuller@gmail.com>
parents:
15
diff
changeset
|
33 engine.set_habitat(start) |
12 | 34 engine.run() |