Mercurial > skaapsteker
comparison skaapsteker/__main__.py @ 633:cd3514bf79b5
Add --fullscreen option.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Fri, 27 Jan 2023 23:18:10 +0100 |
parents | 0675f390653c |
children |
comparison
equal
deleted
inserted
replaced
632:0675f390653c | 633:cd3514bf79b5 |
---|---|
4 import os | 4 import os |
5 import sys | 5 import sys |
6 import optparse | 6 import optparse |
7 | 7 |
8 import pygame | 8 import pygame |
9 from pygame.locals import SWSURFACE, FULLSCREEN | 9 from pygame.locals import SWSURFACE |
10 | 10 |
11 from . import options | 11 from . import options |
12 from .constants import SCREEN | 12 from .constants import SCREEN |
13 from .data import filepath | 13 from .data import filepath |
14 from .engine import Engine | 14 from .engine import Engine |
32 | 32 |
33 def parse_args(args): | 33 def parse_args(args): |
34 parser = optparse.OptionParser() | 34 parser = optparse.OptionParser() |
35 parser.add_option("--no-sound", action="store_false", default=True, | 35 parser.add_option("--no-sound", action="store_false", default=True, |
36 dest="sound", help="disable sound") | 36 dest="sound", help="disable sound") |
37 parser.add_option("--fullscreen", action="store_true", default=False, | |
38 dest="fullscreen", help="enable fullscreen") | |
37 parser.add_option("--dvorak", action="store_true", default=False, | 39 parser.add_option("--dvorak", action="store_true", default=False, |
38 dest="dvorak", help="Dvorak keyboard layout") | 40 dest="dvorak", help="Dvorak keyboard layout") |
39 parser.add_option("--save-location", action="store", default=_get_default_save_location(), | 41 parser.add_option("--save-location", action="store", default=_get_default_save_location(), |
40 dest="save_location", help="Saved game location") | 42 dest="save_location", help="Saved game location") |
41 if DEBUG: | 43 if DEBUG: |
46 parser.add_option("--show-rects", action="store_true", default=False, | 48 parser.add_option("--show-rects", action="store_true", default=False, |
47 dest="rects", help="Disable debugging rects") | 49 dest="rects", help="Disable debugging rects") |
48 opts, _ = parser.parse_args(args or []) | 50 opts, _ = parser.parse_args(args or []) |
49 options['dvorak'] = opts.dvorak | 51 options['dvorak'] = opts.dvorak |
50 options['sound'] = opts.sound | 52 options['sound'] = opts.sound |
53 options['fullscreen'] = opts.fullscreen | |
51 options['save_location'] = opts.save_location | 54 options['save_location'] = opts.save_location |
52 if DEBUG: | 55 if DEBUG: |
53 options['debug_rects'] = opts.rects | 56 options['debug_rects'] = opts.rects |
54 options['all_tails'] = opts.all_tails | 57 options['all_tails'] = opts.all_tails |
55 return opts.level | 58 return opts.level |
60 """ | 63 """ |
61 level = parse_args(sys.argv) | 64 level = parse_args(sys.argv) |
62 pygame.display.init() | 65 pygame.display.init() |
63 pygame.font.init() | 66 pygame.font.init() |
64 soundsystem = SoundSystem(options['sound']) | 67 soundsystem = SoundSystem(options['sound']) |
65 pygame.display.set_mode(SCREEN, SWSURFACE | FULLSCREEN) | 68 screen_flags = SWSURFACE |
69 if options['fullscreen']: | |
70 screen_flags |= getattr(pygame, 'FULLSCREEN', 0) | |
71 pygame.display.set_mode(SCREEN, screen_flags) | |
66 pygame.display.set_icon(pygame.image.load(filepath('icons/program/icon_24.png'))) | 72 pygame.display.set_icon(pygame.image.load(filepath('icons/program/icon_24.png'))) |
67 pygame.display.set_caption("Nine Tales") | 73 pygame.display.set_caption("Nine Tales") |
68 | 74 |
69 engine = Engine(soundsystem) | 75 engine = Engine(soundsystem) |
70 if level is not None: | 76 if level is not None: |