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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
3ab5097e8757 Refactor options.
Simon Cross <hodgestar@gmail.com>
parents: 30
diff changeset
7 from mamba.constants import SCREEN
3ab5097e8757 Refactor options.
Simon Cross <hodgestar@gmail.com>
parents: 30
diff changeset
8 from mamba.options import options, parse_args
12
0196455fa432 Minimal event loop.
Simon Cross <hodgestar@gmail.com>
parents: 11
diff changeset
9 from mamba.engine import Engine
30
cccf1675731c Add sound framework
Neil Muller <drnlmuller@gmail.com>
parents: 26
diff changeset
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
08941f788c15 Skellington! Inna repo!
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
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
3ab5097e8757 Refactor options.
Simon Cross <hodgestar@gmail.com>
parents: 30
diff changeset
17 parse_args(sys.argv)
3ab5097e8757 Refactor options.
Simon Cross <hodgestar@gmail.com>
parents: 30
diff changeset
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
0196455fa432 Minimal event loop.
Simon Cross <hodgestar@gmail.com>
parents: 11
diff changeset
24 engine = Engine()
39
3ab5097e8757 Refactor options.
Simon Cross <hodgestar@gmail.com>
parents: 30
diff changeset
25 if options.level is None:
3ab5097e8757 Refactor options.
Simon Cross <hodgestar@gmail.com>
parents: 30
diff changeset
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
3ab5097e8757 Refactor options.
Simon Cross <hodgestar@gmail.com>
parents: 30
diff changeset
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
0196455fa432 Minimal event loop.
Simon Cross <hodgestar@gmail.com>
parents: 11
diff changeset
34 engine.run()