Changeset 411:03d5cb669298


Ignore:
Timestamp:
Nov 21, 2009, 11:18:08 AM (11 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68/trunk/rinkhals@416
Message:

Add config file and command line parameters.

Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • gamelib/engine.py

    r396 r411  
    149149        elif e.type is KEYDOWN and e.key == K_ESCAPE:
    150150            self.dialog = check_exit()
    151         elif e.type is ANIM_ID:
    152             self.game.gameboard.run_animations()
    153151        elif e.type is KEYDOWN and e.key == K_n:
    154152            return pygame.event.post(START_NIGHT)
     
    213211        elif e.type is KEYDOWN and e.key == K_ESCAPE:
    214212            self.dialog = check_exit()
    215         elif e.type is ANIM_ID:
    216             self.game.gameboard.run_animations()
    217213        elif e.type is MOVE_FOX_ID:
    218214            # ensure no timers trigger while we're running
  • gamelib/main.py

    r389 r411  
    77'''
    88
     9import sys
     10
    911import pygame
    1012from pgu import gui
     
    1416from sound import init_sound
    1517import constants
     18from config import config
    1619import data
    17 import sys
    1820
    1921def create_main_app(screen):
     
    2729def main():
    2830    """Main script."""
     31    config.configure(sys.argv[1:])
    2932    init_sound()
    3033    screen = pygame.display.set_mode(constants.SCREEN, SWSURFACE)
     
    3538    from engine import Engine, MainMenuState
    3639
    37     if len(sys.argv) > 1:
    38         level_name = sys.argv[1]
    39     else:
    40         level_name = 'two_weeks'
    41 
    42     engine = Engine(main_app, level_name)
     40    engine = Engine(main_app, config.level_name)
    4341    try:
    4442        engine.run(MainMenuState(engine), screen)
  • gamelib/sound.py

    r363 r411  
    11import os
    2 import pygame
    32import sys
    43
     4import pygame
     5
    56import data
     7from config import config
    68import constants
    79
     
    1113    """initialize the sound system"""
    1214    global SOUND_INITIALIZED
     15    if not config.sound:
     16        return
    1317    try:
    1418        pygame.mixer.init(constants.FREQ, constants.BITSIZE, constants.CHANNELS, constants.BUFFER)
     
    2125def play_sound(filename):
    2226    """plays the sound with the given filename from the data sounds directory"""
    23     if not SOUND_INITIALIZED:
     27    if not (SOUND_INITIALIZED and config.sound):
    2428        return
    2529    file_path = data.filepath("sounds", filename)
     
    3640    """stops any playing background music"""
    3741    global CURRENT_MUSIC_FILE
    38     if not SOUND_INITIALIZED:
     42    if not (SOUND_INITIALIZED and config.sound):
    3943        return
    4044    CURRENT_MUSIC_FILE = None
     
    4549    """plays the background music with the given filename from the data sounds directory"""
    4650    global CURRENT_MUSIC_FILE
    47     if not SOUND_INITIALIZED:
     51    if not (SOUND_INITIALIZED and config.sound):
    4852        return
    4953    file_path = data.filepath("sounds", filename)
Note: See TracChangeset for help on using the changeset viewer.