Changeset 6:be641ad97aaa


Ignore:
Timestamp:
Apr 3, 2011, 1:30:22 PM (9 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Message:

Create a pygame window.

Location:
skaapsteker
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/__main__.py

    r0 r6  
     1"""Game main module.
     2   """
     3
     4from constants import SCREEN, FREQ, BITSIZE, CHANNELS, BUFFER, DEBUG
     5
     6import pygame
     7from pygame.locals import SWSURFACE
     8
     9import sys
     10import optparse
     11
     12
     13
     14def parse_args(args):
     15    parser = optparse.OptionParser()
     16    parser.add_option("--no-sound", action="store_false", default=True,
     17            dest="sound", help="disable sound")
     18    if DEBUG:
     19        parser.add_option("--scene", type="str", default=None,
     20            dest="scene", help="initial scene")
     21        parser.add_option("--no-rects", action="store_false", default=True,
     22            dest="rects", help="disable debugging rects")
     23    opts, _ = parser.parse_args(args or [])
     24    return opts
     25
    126
    227def main():
    3     """ your app starts here
    4     """
     28    """Launch Nine Tales.
     29       """
     30    opts = parse_args(sys.argv)
     31    pygame.display.init()
     32    pygame.font.init()
     33    if opts.sound:
     34        try:
     35            pygame.mixer.init(FREQ, BITSIZE, CHANNELS, BUFFER)
     36        except pygame.error, exc:
     37            raise
     38            # TODO: bail out to no_sound(exc)
     39    else:
     40        # Ensure get_sound returns nothing, so everything else just works
     41        # TODO: bail out to disable_sound()
     42        pass
     43
     44    display =  pygame.display.set_mode(SCREEN, SWSURFACE)
     45    #pygame.display.set_icon(pygame.image.load(
     46    #    data.filepath('icons/nine_tales24x24.png')))
     47    pygame.display.set_caption("Nine Tales")
     48
     49    raw_input('?')
     50
     51    #shell = MainShell(display)
     52    #try:
     53    #    shell.run()
     54    #except KeyboardInterrupt:
     55    #    pass
Note: See TracChangeset for help on using the changeset viewer.