# HG changeset patch # User Simon Cross # Date 1301837422 -7200 # Node ID be641ad97aaa1b7310d136994bd29d16e9401f68 # Parent 73162df1af934bf28f8365ebdf7e73d53945e696 Create a pygame window. diff -r 73162df1af93 -r be641ad97aaa skaapsteker/__main__.py --- a/skaapsteker/__main__.py Sun Apr 03 15:24:23 2011 +0200 +++ b/skaapsteker/__main__.py Sun Apr 03 15:30:22 2011 +0200 @@ -1,4 +1,55 @@ +"""Game main module. + """ + +from constants import SCREEN, FREQ, BITSIZE, CHANNELS, BUFFER, DEBUG + +import pygame +from pygame.locals import SWSURFACE + +import sys +import optparse + + + +def parse_args(args): + parser = optparse.OptionParser() + parser.add_option("--no-sound", action="store_false", default=True, + dest="sound", help="disable sound") + if DEBUG: + parser.add_option("--scene", type="str", default=None, + dest="scene", help="initial scene") + parser.add_option("--no-rects", action="store_false", default=True, + dest="rects", help="disable debugging rects") + opts, _ = parser.parse_args(args or []) + return opts + def main(): - """ your app starts here - """ + """Launch Nine Tales. + """ + opts = parse_args(sys.argv) + pygame.display.init() + pygame.font.init() + if opts.sound: + try: + pygame.mixer.init(FREQ, BITSIZE, CHANNELS, BUFFER) + except pygame.error, exc: + raise + # TODO: bail out to no_sound(exc) + else: + # Ensure get_sound returns nothing, so everything else just works + # TODO: bail out to disable_sound() + pass + + display = pygame.display.set_mode(SCREEN, SWSURFACE) + #pygame.display.set_icon(pygame.image.load( + # data.filepath('icons/nine_tales24x24.png'))) + pygame.display.set_caption("Nine Tales") + + raw_input('?') + + #shell = MainShell(display) + #try: + # shell.run() + #except KeyboardInterrupt: + # pass diff -r 73162df1af93 -r be641ad97aaa skaapsteker/constants.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skaapsteker/constants.py Sun Apr 03 15:30:22 2011 +0200 @@ -0,0 +1,10 @@ +# Useful constants +# copyright skaapsteker team (see COPYRIGHT file for details) + +SCREEN = (800, 600) +FREQ = 44100 # same as audio CD +BITSIZE = -16 # unsigned 16 bit +CHANNELS = 2 # 1 == mono, 2 == stereo +BUFFER = 1024 # audio buffer size in no. of samples + +DEBUG = False