annotate gamelib/main.py @ 142:1597081e5a84

Disable timer when game is over
author Neil Muller <drnlmuller@gmail.com>
date Wed, 02 Sep 2009 23:08:29 +0000
parents 1d73de63bd71
children 082868bea873
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
e057e9483488 Added pyweek skellington.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
1 '''Game main module.
e057e9483488 Added pyweek skellington.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
2
e057e9483488 Added pyweek skellington.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
3 Contains the entry point used by the run_game.py script.
e057e9483488 Added pyweek skellington.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
4
e057e9483488 Added pyweek skellington.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
5 Feel free to put all your game code here, or in other modules in this "gamelib"
e057e9483488 Added pyweek skellington.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
6 package.
e057e9483488 Added pyweek skellington.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
7 '''
e057e9483488 Added pyweek skellington.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
8
4
e8ddbc95cbf3 Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents: 2
diff changeset
9 import pygame
e8ddbc95cbf3 Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents: 2
diff changeset
10 from pgu import gui
11
5d58a5b13731 Extremely rudimentary game engine.
Simon Cross <hodgestar@gmail.com>
parents: 7
diff changeset
11 from pygame.locals import SWSURFACE
4
e8ddbc95cbf3 Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents: 2
diff changeset
12
124
69fd96eafde8 Display splash screen and replace window title.
Jeremy Thurgood <firxen@gmail.com>
parents: 90
diff changeset
13 from mainmenu import MenuContainer, MainMenu
11
5d58a5b13731 Extremely rudimentary game engine.
Simon Cross <hodgestar@gmail.com>
parents: 7
diff changeset
14 from engine import Engine, MainMenuState
90
23a8b2e49e9f Added ability to initialize sound and play sounds, and handle sound not working / file being missing etc
David Fraser <davidf@sjsoft.com>
parents: 58
diff changeset
15 from sound import init_sound
5
67b79658b047 Refactor and simplify menu.
Simon Cross <hodgestar@gmail.com>
parents: 4
diff changeset
16 import constants
4
e8ddbc95cbf3 Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents: 2
diff changeset
17
139
1d73de63bd71 Add basic game over screen
Neil Muller <drnlmuller@gmail.com>
parents: 124
diff changeset
18
5
67b79658b047 Refactor and simplify menu.
Simon Cross <hodgestar@gmail.com>
parents: 4
diff changeset
19
139
1d73de63bd71 Add basic game over screen
Neil Muller <drnlmuller@gmail.com>
parents: 124
diff changeset
20 def create_app():
1d73de63bd71 Add basic game over screen
Neil Muller <drnlmuller@gmail.com>
parents: 124
diff changeset
21 """Create the app."""
1d73de63bd71 Add basic game over screen
Neil Muller <drnlmuller@gmail.com>
parents: 124
diff changeset
22 app = gui.App()
11
5d58a5b13731 Extremely rudimentary game engine.
Simon Cross <hodgestar@gmail.com>
parents: 7
diff changeset
23 return app
5
67b79658b047 Refactor and simplify menu.
Simon Cross <hodgestar@gmail.com>
parents: 4
diff changeset
24
11
5d58a5b13731 Extremely rudimentary game engine.
Simon Cross <hodgestar@gmail.com>
parents: 7
diff changeset
25 def main():
5d58a5b13731 Extremely rudimentary game engine.
Simon Cross <hodgestar@gmail.com>
parents: 7
diff changeset
26 """Main script."""
90
23a8b2e49e9f Added ability to initialize sound and play sounds, and handle sound not working / file being missing etc
David Fraser <davidf@sjsoft.com>
parents: 58
diff changeset
27 init_sound()
11
5d58a5b13731 Extremely rudimentary game engine.
Simon Cross <hodgestar@gmail.com>
parents: 7
diff changeset
28 screen = pygame.display.set_mode(constants.SCREEN, SWSURFACE)
139
1d73de63bd71 Add basic game over screen
Neil Muller <drnlmuller@gmail.com>
parents: 124
diff changeset
29 main_app = create_app()
1d73de63bd71 Add basic game over screen
Neil Muller <drnlmuller@gmail.com>
parents: 124
diff changeset
30 engine = Engine(main_app)
58
2afdccfb9c67 Hide keyboard interrupt message on Ctrl-C exit.
Simon Cross <hodgestar@gmail.com>
parents: 11
diff changeset
31 try:
2afdccfb9c67 Hide keyboard interrupt message on Ctrl-C exit.
Simon Cross <hodgestar@gmail.com>
parents: 11
diff changeset
32 engine.run(MainMenuState(engine), screen)
2afdccfb9c67 Hide keyboard interrupt message on Ctrl-C exit.
Simon Cross <hodgestar@gmail.com>
parents: 11
diff changeset
33 except KeyboardInterrupt:
2afdccfb9c67 Hide keyboard interrupt message on Ctrl-C exit.
Simon Cross <hodgestar@gmail.com>
parents: 11
diff changeset
34 pass