view gamelib/main.py @ 232:75033f790e7d

Remove hooks for sound support - we can add them back easily enough later
author Neil Muller <drnlmuller@gmail.com>
date Sat, 12 May 2012 23:37:24 +0200
parents 80cce62f29fb
children
line wrap: on
line source

'''Game main module.

Contains the entry point used by the run_game.py script.

Feel free to put all your game code here, or in other modules in this "gamelib"
package.
'''
import pygame
import optparse
import sys

from gamelib.engine import Engine
from gamelib.data import load_image
from gamelib.mainmenu import MainMenu

from gamelib.constants import SCREEN, WINDOW_ICON


def parse_args(args):
    parser = optparse.OptionParser()

    parser.add_option('--load', type="string", default=None,
            dest="load", help="Save game to load")

    return parser.parse_args(args)


def main():
    opts, args = parse_args(sys.argv)
    pygame.display.init()
    pygame.font.init()
    screen = pygame.display.set_mode(SCREEN)
    pygame.display.set_icon(load_image(WINDOW_ICON))
    engine = Engine(screen)
    window = MainMenu(screen, opts.load)
    engine.run(window)