Changeset 105:c455b7925212


Ignore:
Timestamp:
Apr 4, 2011, 7:05:33 PM (9 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Message:

Global options in skaapsteker.init

Location:
skaapsteker
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/__init__.py

    r79 r105  
     1options = {
     2    'debug_rects': False,
     3    'sound': True,
     4}
  • skaapsteker/__main__.py

    r79 r105  
    22   """
    33
     4import sys
     5import optparse
     6
     7import pygame
     8from pygame.locals import SWSURFACE
     9
     10from . import options
    411from .constants import SCREEN, FREQ, BITSIZE, CHANNELS, BUFFER, DEBUG
    512from .engine import Engine
    613from .levelscene import LevelScene
    714from .menuscene import MenuScene
    8 
    9 import pygame
    10 from pygame.locals import SWSURFACE
    11 
    12 import sys
    13 import optparse
    1415
    1516
     
    2021    if DEBUG:
    2122        parser.add_option("--level", type="str", default=None,
    22             dest="level", help="initial level")
     23            dest="level", help="Initial level")
    2324        parser.add_option("--no-rects", action="store_false", default=True,
    24             dest="rects", help="disable debugging rects")
     25            dest="rects", help="Disable debugging rects")
    2526    opts, _ = parser.parse_args(args or [])
    26     return opts
     27    options['sound'] = opts.sound
     28    if DEBUG:
     29        options['debug_rects'] = opts.rects
     30        return opts.level
    2731
    2832
     
    3034    """Launch Nine Tales.
    3135       """
    32     opts = parse_args(sys.argv)
     36    level = parse_args(sys.argv)
    3337    pygame.display.init()
    3438    pygame.font.init()
    35     if opts.sound:
     39    if options['sound']:
    3640        try:
    3741            pygame.mixer.init(FREQ, BITSIZE, CHANNELS, BUFFER)
     
    4953    pygame.display.set_caption("Nine Tales")
    5054
    51     level = getattr(opts, 'level', None)
    52 
    5355    engine = Engine()
    5456    if level is not None:
  • skaapsteker/physics.py

    r104 r105  
    44   """
    55
     6import time
     7
     8import pygame
     9import pygame.draw
    610import pygame.sprite
    7 import pygame.draw
    8 import pygame
    9 import time
    10 from constants import DEBUG, EPSILON
     11
     12from . import options
     13from .constants import EPSILON
    1114
    1215class Sprite(pygame.sprite.DirtySprite):
     
    163166    def draw(self, surface):
    164167        self._all.draw(surface)
    165         if DEBUG:
     168        if options['debug_rects']:
    166169            for sprite in self._all:
    167170                sprite.draw_debug(surface)
Note: See TracChangeset for help on using the changeset viewer.