source: gamelib/main.py@ 411:03d5cb669298

Last change on this file since 411:03d5cb669298 was 411:03d5cb669298, checked in by Jeremy Thurgood <firxen@…>, 11 years ago

Add config file and command line parameters.

File size: 1.1 KB
Line 
1'''Game main module.
2
3Contains the entry point used by the run_game.py script.
4
5Feel free to put all your game code here, or in other modules in this "gamelib"
6package.
7'''
8
9import sys
10
11import pygame
12from pgu import gui
13from pygame.locals import SWSURFACE
14
15#from engine import Engine, MainMenuState
16from sound import init_sound
17import constants
18from config import config
19import data
20
21def create_main_app(screen):
22 """Create an app with a background widget."""
23 app = gui.App()
24 background = pygame.Surface(screen.get_size())
25 widget = gui.Image(background)
26 app.init(widget, screen)
27 return app
28
29def main():
30 """Main script."""
31 config.configure(sys.argv[1:])
32 init_sound()
33 screen = pygame.display.set_mode(constants.SCREEN, SWSURFACE)
34 pygame.display.set_icon(pygame.image.load(
35 data.filepath('icons/foxassault24x24.png')))
36 main_app = create_main_app(screen)
37
38 from engine import Engine, MainMenuState
39
40 engine = Engine(main_app, config.level_name)
41 try:
42 engine.run(MainMenuState(engine), screen)
43 except KeyboardInterrupt:
44 pass
Note: See TracBrowser for help on using the repository browser.